I have a problem with configuring an EDMX file that lives in an other assembly than by web project. My project looks somewhat like this:
Project 1
--> Dat
Easier way is to take connection string from Web.Config and copy them into App.Config and point EDMX's connectionstring to same DB information. e.g
<connectionStrings>
<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
<add name="aspnetdbEntities" connectionString="metadata=res://*/Data.PSBData.csdl|res://*/Data.PSBData.ssdl|res://*/Data.PSBData.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\aspnetdb.mdf;integrated security=True;user instance=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
Also you need to check if the namespaces are correct if you have moved Database.edmx from Project 2 to Project 1, which you can check by opening Database.edmx and goto code behind.
You have to change the *
in the connection string for the assembly name where the .edmx files are in:
<add name="Entities" connectionString="metadata=res://*/Models.EF.Model.csdl|res://*/Models.EF.Model.ssdl|res://*/Models.EF.Model.msl;provider=System.Data.SqlClient;provider connection ... ;" providerName="System.Data.EntityClient" />
for
<add name="Entities" connectionString="metadata=res://Project2/Models.EF.Model.csdl|res://Project2/Models.EF.Model.ssdl|res://Project2/Models.EF.Model.msl;provider=System.Data.SqlClient;provider connection ... ;" providerName="System.Data.EntityClient" />
As it turned out, there were 2 problems. One was solved replacing the * in the connection string.
The second problem was the one described here: http://blogs.teamb.com/craigstuntz/2010/08/13/38628/
It had to do with the path .csdl, .ssdl and .msl files had as resources inside the Project1 assembly
Anyway, things function properly now