Enable Entity Framework automatic data migration in MVC Core

 Author: Shengtao Zhou       Created: 1/21/2019 9:12:36 PM       Modified: 2/2/2019 3:09:15 AM   More...
You may want to enable EF automatic migration, so when the application gets the first request, it will show a button on the page, you can click and create a database or deploy database change.

You only need to add Database Migrate() to the constructor of your DbContext file. (If you selected Individual user login option when you create the project, the context file will be,
"\Models\Data\ApplicationDbContext.cs".)

        public ApplicationDbContext(DbContextOptions options)
            : base(options)
        {
            Database.Migrate();
        }

More...          Back to List          

(Please enter you comments between 100 to 2000 characters. Thanks for your contribution.) 

         Created:       Modified: 

Editing a comment

       (Please enter you comments between 100 to 2000 characters. Please login before edit comment.)