I use Entity Framework 6. I have an app.config
file in my project and it has a connection string like below
<connectionStrings>
<add name="ConnStrDev"
connectionString="Server=.\SqlExpress;Database=Dev;Trusted_Connection=True;"/>
</connectionStrings>
When I create this database via enable-migrations
command, EF uses a name for this database like ConnStrDev
.
But my expectation was using a database name like Dev
because of the connection string's database name.
My DbContext
source looks like this
public MyDbContext() : base("ConnStrDev")
Why does EF use a database name of ConnStrDev
, instead of Dev
?
Thank you
EF uses Connection string Name in the app.config
as DataBase Name. you can rename Connection string name in config file and dbcontext
public MyDbContext() : base("dev")
<connectionStrings>
<add name="dev"
connectionString="Server=.\SqlExpress;Database=Dev;Trusted_Connection=True;"/>
</connectionStrings>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.