Dani
Dani

Reputation: 15081

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 ?

Upvotes: 6

Views: 2439

Answers (1)

Jeff Ogata
Jeff Ogata

Reputation: 57833

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=...

Upvotes: 12

Related Questions