Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit model-snapshot for perf #18620

Open
ajcvickers opened this issue Oct 28, 2019 · 6 comments
Open

Revisit model-snapshot for perf #18620

ajcvickers opened this issue Oct 28, 2019 · 6 comments

Comments

@ajcvickers
Copy link
Contributor

ajcvickers commented Oct 28, 2019

At the beginning of EF Core we decided that we would use the fluent API in model snapshots rather than designing a new serialization format. (In other words, the fluent API is the way to serialize the model.) However, this can lead to a lot of code compiled for big models and when the number of migrations build up. See, for example, #18618.

We should consider:

@AndriySvyryd
Copy link
Member

AndriySvyryd commented Oct 30, 2019

Note that this will likely mean that snapshots will need to be updated for major version upgrades and possibly minor ones. So we should consider #18557 at the same time

@bricelam
Copy link
Contributor

bricelam commented Nov 1, 2019

Another idea I has was to only put the store model in the *.Designer.cs files, but this doesn't work since we need the full model when removing a migration.

@ajcvickers
Copy link
Contributor Author

We believe this is best handled by squashing migrations: #2174

@ajcvickers
Copy link
Contributor Author

Re-open to consider using the relational model.

@Tasteful
Copy link
Contributor

I was trying to work around this in our product that have ~440 migrations and we can't squash them into a single to get a fresh start because the product is installed on-premises at customer and different customer is in different stage of upgrades in versioning.

I come up to the solution where I created a MSBuild task that extracting the attributes from the *.Designer.cs files and generated a new file. Then I adding a targets file that excluding all the *.Designer.cs files and including the generated file. This somehow is working in many cases but some CreateIndexOperations will add an filter [Id] IS NOT NULL even on non-nullable properties and this does not happen when running the original code.

The generated file does not contain the BuildTargetModel file where all the metadata about the model at that time the model was created is ignored, this reduced the size for the built assembly from 32 MB to 2 MB and build time from 2 minutes and 30 seconds to 8 seconds so that is a good improvements in speed.

Does it exists any information about how the model in BuildTargetModel is used during migration up command?

Should it work to run the migrations up command without the model in BuildTargetModel ?

@bricelam
Copy link
Contributor

Does it exists any information about how the model in BuildTargetModel is used during migration up command?

This answer is old and there are probably more cases now, but it should give you an idea of how the model is used..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants