Update ContextModelSnapshot EF Core

asp.net-core-mvc entity-framework-core

Question

I'm newer to EF Core, so please forgive me if there is a trivial answer.

Take this scenario....

A new web-application is being developed using the latest version of ASP.NET Core, with a code-first approach. At some point, the ContextModelSnapshot became out of sync with the database, due to deletions or source control. We cannot delete the database and recreate it.

Question: How can the snapshot be 're-synced' with the database?

1
7
5/4/2018 6:33:49 PM

Popular Answer

You can execute the command

Add-migration

to create a new empty migration. Then, run

Remove-Migration(or their dotnet-cli counterparts)

It will Revert model snapshot even if the migration has already been deleted. This approach works perfectly for Ef core 2.2.0-rtm-35687

4
3/1/2019 6:27:27 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow