Click here to Skip to main content
15,607,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want Update database by code first migration .for example I have 3 entity in contex and 1 table in database and there is a problem when I run program and get this error:There is already table.


Migration Configuration
C#
 internal sealed class Configuration : DbMigrationsConfiguration<ApplicationDbContext>
{
    public Configuration()
    {
        AutomaticMigrationsEnabled = false;
       // AutomaticMigrationDataLossAllowed = false;
    }

    protected override void Seed(ApplicationDbContext context)
    {
        //  This method will be called after migrating to the latest version.


    }
}



IdentityModel

C#
public ApplicationDbContext() : base("DefaultConnection" )
    {
        Database.SetInitializer<applicationdbcontext>(new MigrateDatabaseToLatestVersion<applicationdbcontext,>());
    }

What I have tried:

I have try update database that is already but I can do it.</applicationdbcontext>
Posted
Updated 6-Jul-16 23:11pm

1 solution

Change AutomaticMigrationsEnabled = false; to AutomaticMigrationsEnabled = true;

and then after every changes in Package Manager Console write following.

PM > Update-Database -Force
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900