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

Question: Is having a non schema-aware DbContextModelSnapshot an issue? It sure looks weird. #2

Open
IgorPietraszko opened this issue Mar 8, 2022 · 1 comment

Comments

@IgorPietraszko
Copy link

I have implemented everything as described in your article Entity Framework Core - Changing DB Migration Schema At Runtime and it works great! Thanks a lot for that as I am using this approach to support a multi-tenant setup on PostgreSQL.
I only have one question - what about DbContextModelSnapshot? It is not schema-aware but does not seem to cause me any issues. Its just weird since it always reflects the latest SCHEMA I generated migrations for. Is it possible to make it schema-aware?

@PawelGerr
Copy link
Owner

The snapshot is being used to detect changes in the model. I recommend using the same schema for creation of new migrations. Otherwise, it could happen that EF creates migrations to change the schema of your tables because the schema in the snapshot differs from the schema in the current model.

It is very likely that the snapshot can be made schewa-aware. Via design-time services we can change almost every part of EF core which is responsible for the generation of the migrations and the snapshot. But, I doubt it is worth the time.

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

No branches or pull requests

2 participants