How to disable Migrations from an EF6 project?

Asked

Viewed 849 times

3

Hello!

I have a class library with models using Code First and enabled Migrations with the command "enable-Migrations" in PMC to test and works very well. As I am at the beginning of the model definitions, I prefer to leave it until after making the first production deploy.

How do I disable Migrations from my project?

1 answer

3

Place false in the AutomaticMigrationsEnabled and when you need it again put true.

Example:

inserir a descrição da imagem aqui

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

You can also use Add-Migration InitialSchema -IgnoreChanges, to create an empty Migration under the current model.

In that link, has videos and interesting explanations on the subject, despite being in English, the text is very easy to understand.

References

Browser other questions tagged

You are not signed in. Login or sign up in order to post.