Ok, this question has been asked many times. Just googling with the error message:
The specified named connection is either not found in the configuration,
not intended to be used with the EntityClient provider, or not valid.
I have tried all suggestions on forums, help sites et blogs... nothing works!
Situation recap
I'm splitting solution into three different projects: one for my model with EF4, one of WinForm and one ASP.NET MVC web application. I have a problem with connections string and configuration.
Is there a updated solution using VS2010/EF4/.NET Framework 4.0?
Not sure, but you may have to move the Entity Framework configuration sections in your EF4 project's app.config file to both your WinForm app.config and ASP.NET MVC web.config files.
Really, the answer is copying the <connectionStrings>
section in the other project's config files like mentionned above.
<connectionStrings>
<add name="DataEntities" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=xxx;Initial Catalog=xxx;User Id=xxx;Password=xxx;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
</connectionStrings>
So, it's the same answer as I saw before on many sites. In fact, it was working from the beginning, but I had another error ("Configuration system failed to initialize"), so I thought it was a wrong value of the connection string in the app.config. In fact, the app.config was valid, but just moving the section on bottom solved this... Bizarre?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With