my seed method works fine when running in local machine, when push code appharbor seed not working.
this connection string:
<connectionstrings> <add name="finalprojectcontext" connectionstring="data source=.\sqlexpress;user id=user;password=pass;initial catalog=mycontextdb;" providername="system.data.sqlclient" /> </connectionstrings> my seed method inside configuration file migrations:
public configuration() { automaticmigrationsenabled = true; automaticmigrationdatalossallowed = true; } protected override void seed(mycontext context) { //add data } and i'm calling seed method context class, inside onmodelcreating:
protected override void onmodelcreating(dbmodelbuilder modelbuilder) { database.setinitializer(new migratedatabasetolatestversion<mycontext, configuration>()); } edit

after lot of debugging, searching, testing , reading, problem wasn't related appharbor per say. project using dbfactory context, , problem occurring. in local machine ef calling initializer every time started application database seeded, in order work in app harbor had set initializer false (explicitly) in dbfactory constructor.
edit
the problem goes further. not sure how ef tracking think if run code locally database gets created locally , ef flags migration "executed", when move code appharborit doesn't seeded. way i've found solve delete database locally , push appharbor.
Comments
Post a Comment