Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Connection Strings Migration

$
0
0

I will start by saying the biggest problem I have may be that I'm not even sure what to search for any more.  Which term should I be using:  "ASP.NET Core", "Web API 2", "MVC 6" "Web Application", "Azure App Service" ...?!?

ANYway....  I have created a brand new "ASP.NET Core Web Application (.NET Framework)" based on the "Web API" template.  My data model ("Entity Framework 6" generated) is in a separate project.  The data model project has the connection string in the "App.config" file just like I'm used to:

<connectionStrings><add name="MyEntities" connectionString="metadata=res://*/MyModel.csdl| ... " providerName="System.Data.EntityClient" /></connectionStrings>

I know I have to have the connection string configured in my "starting" application, but I can't seem to figure out how.  My ASP.NET project has several different configuration files, including "app.config", "web.config", and "appsettings.json".  I've tried putting the above into both the "app.config" and the "web.config", and tried a variant in the "appsettings.json", but to no avail.  (I already have the ".AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)" statement in my "Startup.cs".)  No matter what I try, I always get an exception with the message "No connection string named 'MyEntities' could be found in the application config file.".  "System.Configuration.ConfigurationManager.ConnectionStrings" is not aware of anything I put into those files.

I can't imagine I'm the first to encounter this, but I've been unsuccessful in finding a solution by searching.  What am I doing wrong?  How should I be doing this?

Thanks!

Brad.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>