Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Entity Framework conversion from v1 to v4 problem

After converting my data access layer project from EntityFramework v1 to v4 a got a bunch of errors for each of the entity classes:

Error 10016: Error resolving item 'EntityTypeShape'. The exception message is: 'Unresolved reference 'NS.EntityName1'.'. DataAccessLayer\Model.edmx

and

Error 10016: Error resolving item 'AssociationConnector'. The exception message is: 'NS.EntityName1'.'. DataAccessLayer\Model.edmx

Does anybody know what is this and how to fix it?

like image 558
Max Avatar asked Jun 17 '10 02:06

Max


2 Answers

If the model is small, it's probably easiest to just regenerate it. If you'd prefer to fix it, you can modify the XML in the XML editor manually, either before or after the conversion. The problem, in my case, was that the EntityType attributes were not correct - specifically the namespace was incorrect. I'm not sure how it even worked correctly in VS2008 but I didn't have the desire to pursue it any further. If you don't mind losing the layout of your model, the easiest way to fix it is to delete everything inside the <Diagram> tag, so that is looks like this:

<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
  <Diagram Name="YourDiagramName">
  </Diagram>
</edmx:Diagrams>

Save it and reopen the model in the designer. The problem should be resolved now.

If you want to preserve your layout, rather than simply deleting everything inside the <Diagram> tag, you'll need to correct any EntityType attributes that aren't correct. The trick is to make sure that the fully qualified type name is specified. In my case, the namespace had something extra in it - not sure how it got there or how it worked in VS2008, but correcting this is the first step. You may want to verify your namespace and entity name by looking at the generated code for the model.

I tried this solution in both VS2008 and VS2010 and got different results. In VS2010, simply correcting the EntityType attributes fixed the problem immediately. In VS2008, I received an error when opening the model again, "The parameter is incorrect." To resolve this issue, I was able to manually edit the XML again. This time I removed all of the <AssociationConnector> tags (and any child elements). Then saved the file and everything seemed to work again.

like image 190
Dominick Avatar answered Nov 15 '22 10:11

Dominick


I had the exact same issue. I don't know if this is your issue or not, but I found by looking at the edmx in the xml view that I had duplicate references in the xml for each of the items with that error. All I had to do was remove the duplicate references and everything worked.

Here's an example of what I mean:

<EntityTypeShape EntityType="PackageManagementEntityModel.Package" Width="1.5" PointX="0.75" PointY="0.75" Height="3.5644742838541665" IsExpanded="true" />
<EntityTypeShape EntityType="PackageManagementEntityModel.ShipLane" Width="1.5" PointX="2.75" PointY="0.75" Height="1.7566536458333331" IsExpanded="true" />
<EntityTypeShape EntityType="PackageManagement.EntityModel.Package" Width="1.5" PointX="0.75" PointY="0.75" Height="3.5844742838541652" />
<EntityTypeShape EntityType="PackageManagement.EntityModel.ShipLane" Width="1.5" PointX="2.625" PointY="0.75" Height="1.7566536458333335" />
like image 44
John Kraft Avatar answered Nov 15 '22 09:11

John Kraft