sql - EF 5 + Azure + MigrationFirst overrides database name. Why? -
i created database in azure setting own custom name. created ef 5 code first entities , added migrations. on application startup called these 2 lines:
database.defaultconnectionfactory = new sqlconnectionfactory(connectionstring); database.setinitializer(new migratedatabasetolatestversion<mydatacontext, myconfiguration>());
connection string taken straight azure: server=tcp:xxx.database.windows.net,1433;database=dbname;user id=yyy;password=zzz;trusted_connection=false;encrypt=true;connection timeout=30;
on fist call expected database dbname filled tables according poco schema. instead new database generated complete namespace name of context: myservice.business.entity.mycontext
why migration not accept database name specified in connection string?
you can specify database name or connection string name in constructor of dbcontext:
public class mydatacontext : dbcontext { public mydatacontext: base("dbnameorconntectionstringnamehere") { } }
Comments
Post a Comment