I have a very simple web part. I have one kind of grid that I populate with linq for objects (or at least what I want to do). The Entity Data.edmx data model file is in the same project as the web part, and everything looks operational. When I debug a project, it explodes the constructor of the entity model with an error message:
The specified named connection is either not found in the configuration, is not intended for use with EntityClient, or is invalid.
My connection string in App.Config is as follows:
<add name="MyDBEntities" connectionString="metadata=res://*/MyDBEntityModel.csdl|res://*/MyDBEntityModel.ssdl|res://*/MyDBEntityModel.msl;provider=System.Data.SqlClient;provider connection string="Data Source=MyServer;Initial Catalog=MyDB;Integrated Security=True;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient" />
Constructor:
public MyDBEntities() : base("name=MyDBEntities", "MyDBEntities")
So, from what I read elsewhere, my problem is that SharePoint cannot see my connection string. This means that the App.Config from my project does not actually load into SharePoint when the project is started / debugged. In this case, as I installed my project in Visual Studio 2010, so that SharePoint builds App.Config in addition to the main SharePoint configuration file. If I need to manually copy the connection string, is there a "best practice" procedure for this? SharePoint Web Parts with Entity Framework Just Not Ready for Prime Time?
source
share