c# - Entity framework 6 add-migration adding all tables/entities in Migration Script -
c# - Entity framework 6 add-migration adding all tables/entities in Migration Script -
i trying run code first migration in entity framework 6.0. have added 4 new entities in entities modal. when run "add-migration" command in vs 2013, generated migration file contains script of entitles (just initial migration) in modal, though in linked database. when rum "update-database" commends, generates entity exists error. dbcontext class looks following:
public class bidstructdbcontext : dbcontext { public bidstructdbcontext() : base(nameorconnectionstring: "bidstruct") { this.configuration.lazyloadingenabled = false; } public dbset<user> users { get; set; } public dbset<role> roles { get; set; } public dbset<permission> permissions { get; set; } public dbset<company> company { get; set; } // new added table public dbset<gadgets> gadgets { get; set; } public dbset<language> language { get; set; } public dbset<languagekeys> translationkeys { get; set; } public dbset<translations> translations { get; set; } static bidstructdbcontext() { database.setinitializer(new databaseinitializer()); } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.conventions.remove<pluralizingtablenameconvention>(); modelbuilder.conventions.remove<onetomanycascadedeleteconvention>(); } }
and databaseinitializer class looks following:
public class databaseinitializer : // createdatabaseifnotexists<bidstructdbcontext> // when model stable dropcreatedatabaseifmodelchanges<bidstructdbcontext> // when iterating { private const int attendeecount = 1000; // ef not way add together lot of new records. // never has been really. not built that. // people should (and do) switch ado , mass insert kind of thing // it's interactive apps humans driving info creation, not machines private const int attendeeswithfavoritescount = 4; protected override void seed(bidstructdbcontext context) { } }
any idea, how resolve problem. working fine me few days facing problem :(
c# asp.net-mvc entity-framework
Comments
Post a Comment