views:

24

answers:

2

What are the possible reasons for getting this error:

"The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."

I am using the auto-generated connection string that the EF Wizard created and added to my app.config, so I would think it should work?

    <add name="CollectionEntities" connectionString="metadata=res://*/CollectionDataModel.csdl|res://*/CollectionDataModel.ssdl|res://*/CollectionDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=devweb\dev;Initial Catalog=Collection2;Persist Security Info=True;User ID=cooluser;Password=coolpassword;MultipleActiveResultSets=True&quot;" providerName="System.Data.EntityClient" />
+1  A: 
Data Source=devweb\dev;Initial Catalog=Collection2;Persist Security Info=True;User ID=cooluser;Password=coolpassword;MultipleActiveResultSets=True

Are these the correct settings for your environment? When you generate a model off local development the connection string reflects the development environment. When you deploy your solution you'll need to update the connection string to reflect the correct server names.

Erik Noren
+1  A: 

No, it won't since you have an ASP.Net MVC project in place and the connection string must be present in the web.config of your MVC project where the runtime will be looking to find it. Basically any connection string should be in the config file of your executable project (i.e. where the .Net thread started from by CLR). So just copy and paste the whole connection string into your web.conig and you're done!

Morteza Manavi
That was it. I needed to copy the conn string to the web.config from the app.config.
Blackcoil