question

EleonoraVasylenko-4575 avatar image
0 Votes"
EleonoraVasylenko-4575 asked JackJJun-MSFT commented

EF Core migration and snapshot are not generated correctly

We are updating our application from .Net Core 3.1 to .Net 6. We have a number of migrations created in .Net Core 3.1. that were created and applied to production long time ago.
When now I run Add-Migration for the first time ever on our application, the newly created migration and DB snapshot doesn't contain all the changes of all the previous migrations. For ex., some properties and not required (although they are configured to be required in old migrations), some indexes are missing (they were created via MigrationBuilder.Sql() method in previous migrations).
We won't apply this initial migration, because we already have these changes in the DB, but we will need the correct snapshot to create subsequent migrations
So I wonder if it is OK to make changes in the DB snapshot to make it correspond to the actual DB state?

dotnet-entity-framework-core
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@EleonoraVasylenko-4575, Welcome to Microsoft Q&A, please refer to the following link to generate the correct snapshot to make it correspond to your current database.

Update ContextModelSnapshot EF Core


0 Votes 0 ·

0 Answers