Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load the specified metadata resource error in Entity Framework 4

I use ASP.NET Webforms and Entity Framework 4 and this is my .edmx file screenshot because I don't know what code to post here:

enter image description here

And this is my connection string in my web.config file:

<add name="tebimir_db_tebimEntities" 
     connectionString="metadata=res://*/DataAccessLayer.tebimir_db_tebim.csdl|res://*/DataAccessLayer.tebimir_db_tebim.ssdl|res://*/DataAccessLayer.tebimir_db_tebim.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=tebim.ir,9993;initial catalog=tebimir_db_tebim;persist security info=True;user id=tebimir_dbadmin;password=qwerty*2607548;MultipleActiveResultSets=True;App=EntityFramework&quot;" 
     providerName="System.Data.EntityClient" />

My .edmx file in inside a folder named DataAccessLayer. When I use Entity Framework, it works fine and there is no problem but ONLY when I create an entityDataSource control and want to assign my .edmx to it, I get an error that the metadata could not be found, otherwise it works correctly.

I mean I can access data using Entity Framework. I checked all the questions related in stack-overflow but could not find an answer. Please help.

enter image description here

These are additional information in case it can help you:

enter image description here enter image description here

like image 884
Ali.Rashidi Avatar asked May 26 '16 09:05

Ali.Rashidi


1 Answers

First of all, you will not face this issue on VS 2012. This is Visual Studio 2013 specific issue and I was able to reproduce it. Here is the solution:

  1. Double click on your edmx file in solution explorer to open it in edmx designer. Right click on empty surface. Click "Model Browser" from context menu.
  2. In Model Browser window select the conceptual model node. It will be parallel to and just below diagrams node. By default name of this node is database name concatenated with string "Model". Like if my database name is Employee then this node is seen as EmployeeModel. Right click on conceptual model node. Click on Properties from the context menu.
  3. Change the value of "Meta Artifact Processing" property from "Embed in Output Assembly" to "Copy to Output Directory"

enter image description here

Now you can point your entityDataSource control to this edmx through Configure Data Source wizard without error. See the note in the ".edmx file properties" section of below link:

https://msdn.microsoft.com/en-us/library/cc982042%28v=vs.100%29.aspx?f=255&MSPPError=-2147217396

like image 83
RBT Avatar answered Oct 27 '22 00:10

RBT