Entity primary code and database deletion

We use EF Code First and Migration for the project. We send our migrations to the source, and everything is fine. However, if someone deletes their database or we get a new person in the project, the database will cause errors because it is trying to start the migration. Is there a way to make sure that if the database does not exist, it ignores migrations? I can't seem to find anything about this.

+4
source share
1 answer

I would see how you use the DbMigrationsConfiguration from the Entity framework. You might need something like this in your global asx file:

    Database.SetInitializer(new MigrateDatabaseToLatestVersion<YourContext, YourConfiguration>());

:

    internal sealed class YourConfiguration : DbMigrationsConfiguration<YourContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = true;
    }...

.

+3

Source: https://habr.com/ru/post/1542229/


All Articles