Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

moving EDMX file to new project caused: System.Data.MetadataException: Unable to load the specified metadata resource

I have a ASP.NET MVC 2 project. I've created edmx file on the class library project that holds the model.

now I've created another class library called it shared and moved the edmx file over there. resolved some issues, everything compiles, but it can't find the connection string resource at runtime.

I've copied the ConnectionString part of the Web.Config to the main file, the old class library app.config file and the new class library app.config file.

Still get this error:

System.Data.MetadataException: Unable to load the specified metadata resource.

Line 75: public myProjdb() : base("name=myProjdb", "MyProjdb")

in the MyProj.Designer.cs file.

Any Idea how to resolve this issue ?

Is there a better way to store connection string data ?

like image 340
Dani Avatar asked Dec 25 '10 19:12

Dani


1 Answers

You should be able to use the same model in other projects if you use a connection string that includes the assembly name. In the connection string you have in web.config, try changing the * in the connection string, from

metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=... 

to something like this:

metadata=res://ClassLibrary1/Model1.csdl|res://ClassLibrary1/Model1.ssdl|res://ClassLibrary1/Model1.msl;provider=System.Data.SqlClient;provider connection string=...
like image 113
Jeff Ogata Avatar answered Jan 04 '23 04:01

Jeff Ogata