How to explicitly name the database when using Entity Framework Migrations 4.3

前端 未结 4 1014
孤城傲影
孤城傲影 2020-12-12 19:04

I\'ve recently started using Entity Framework migrations and noticed that the database name is not pulling through for me when I run the Update-Database command

4条回答
  •  无人及你
    2020-12-12 19:46

    You can have your connection string stored in the web.config in your website project and the DBContext and migration files in another project and still share the same connection string. However you need to make sure that as well as setting the Data project (or whatever project has the DBContext etc. in it) as the default project for the Package Manager Console, you ALSO need to make sure that your website is set to the Default StartUp Project!!!

    I cannot see this documented anywhere, but a frantic 24 hours of not being able to figure out why my migrations where suddenly being applied to a SQLExpress db, led me to this conclusion.

提交回复
热议问题