8

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Ali.Rashidi
  • 1,284
  • 4
  • 22
  • 51

2 Answers2

4

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

RBT
  • 24,161
  • 21
  • 159
  • 240
  • I did, That way I get the same error when im not using entityDataSource control to access my data. EntityDataSource is ok now but I cant access my data directly. – Ali.Rashidi Jun 02 '16 at 17:42
  • I had done this before. I agree that this answer is correct about EntityDataSource but not an answer about the problem. Thanks any way – Ali.Rashidi Jun 02 '16 at 17:44
  • What do you mean by this `That way I get the same error when im not using entityDataSource control to access my data`? What is that error? Are you saying that after making all the changes I've suggested when you actually bind the edmx to control, the entityDataSource doesn't get the records present in database? – RBT Jun 02 '16 at 23:06
  • No! when I bind the edmx to control, say gridview, fields are not retrieved. column names are unknown, when i refresh gridview schema it gives error. i dont know. whatever i just created another project and recreated everything from start. I really hate microsoft products. – Ali.Rashidi Jun 03 '16 at 13:17
  • I will look into it if I also face the same issue with grid view control. Unfortunately the machine on which I was running your code on VS 2013 has been shut down due to a maintenance work over the weekend :( – RBT Jun 04 '16 at 00:16
  • 1
    Anyway i give you the bounty. thanks for your efforts. – Ali.Rashidi Jun 04 '16 at 09:53
3

It seems that you have misconfigured the property MetadataArtifactProcessing.

Try setting MetadataArtifactProcessing = EntityDeploy

Michael
  • 10,124
  • 1
  • 34
  • 49