Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EntityFramework Migration Specify web.config

I am using MV4 and EF5. Is there a way to have EntityFramework Migration pull the connection string from web.debug.config or web.release.config.

Running update-database seems to throw an error unless the connection string is in web.config

like image 529
Chadit Avatar asked Mar 13 '13 13:03

Chadit


People also ask

Can .NET core have web config?

The web. config file has also been replaced in ASP.NET Core. Configuration itself can now be configured, as part of the application startup procedure described in Startup.

Does .NET 5 Use Web config?

In the past Web. config was used for both IIS configuration and application configuration and settings. But in asp.net 5 it is not used by the application at all, it is only used for IIS configuration. This decoupling of the application from IIS is part of what makes cross platform possible.

Is Web config mandatory?

Yes, we can run an ASP.NET web application without web. config file but without in debugging mode. If we don't configure any settings in web. config file then it consider machine.


1 Answers

That's because web.config is where the connection string should be found. Web.release.config and Web.debug.config are configuration transformations based on the current "Solution Configuration". See this MSDN article for details.

The short answer is, of course the connection string is expected to be in Web.config, because that's where it's designed to live.

You can use the -ConnectionStringName or -ConnectionString parameter on Update-Database to specify a different connection for the migrations.

like image 193
Michael Dunlap Avatar answered Oct 12 '22 04:10

Michael Dunlap