Skip to content

Document strategies for dealing with a large number of migrations #2147

Description

@jirikanda

This is just a feedback of daily EF Core use. No action required.

Situation

We have a project with 450+ tables. Database structure is maintained by Entity Framework Core 2.x and Migrations. Currently, there is 350 migrations. Part of *.designer.cs files is each 2MB large. The whole Migrations folder contains files with size 640 MB.

Observation

During build, csc.exe or vbcscompiler.exe consumes up to 12GB RAM. We consider this as high usage.
We created csc.exe memory dump. The analysis revealed only Roslyn data structures (like MemberAccessExpressionSyntax, InvocationExpresionSyntax, ExpressionStatementSyntax), nothing shows a problem, just a Roslyn feature of compiling so many so large files.

Workaround

We process migration "squash" once a while - we delete all migrations and create a new one initial migration. This is done manually, and it is very annoying.
We also need handle the situation on productions sites with already applied migrations, no problem here.

Suggestion

We would appreciate cleaning or deleting *.Designer.cs files of previous migrations when creating a new migration. But we found some minor issue in generating SQL statements when cleaned designer files manually.

Note

We do not wish to use bounded contexts.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions