Entity Framework Migrations - Enable AutoMigrations along with added migration

后端 未结 6 1582
青春惊慌失措
青春惊慌失措 2021-02-04 09:34

I\'m utilizing Entity Framework 4.3 Migrations in my project. I would like to use Automatic migrations so that when I make modifications to my domain objects and my context cla

6条回答
  •  余生分开走
    2021-02-04 09:56

    If your application contains Startup.cs class, you can use DbMigrator Class as follows Go to your App_Start folder, open Startup.Auth Paste these lines of code inside of ConfigureAuth method

    var configuration = new Migrations.Configuration();
            var dbmigrator = new DbMigrator(configuration);
            dbmigrator.Update();
    

    NOTE: Remember to use this namespace- using System.Data.Entity.Migrations;

    what this does is to update your database to the latest version anytime the application starts up

提交回复
热议问题