4

How do we use data migrations in asp.net core? I'v tried looking through the asp.net core documentation but couldn't find anything.

This was the code for asp.net 4:

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

    protected override void Seed(ApplicationDbContext context)
    {
        base.Seed(context);

        //Add stuff to database

        context.SaveChanges();
    }
}

What is the equivalent in asp.net core?

2

1 Answer 1

2

If you're using EF core: https://docs.efproject.net/en/latest/miscellaneous/cli/dotnet.html

If you're using EF 6.x, you may need a community one: https://github.com/mrahhal/Migrator.EF6

Sign up to request clarification or add additional context in comments.

1 Comment

Are you saying Database.SetInitializer() etc can't be used at all in EF Core?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.