Bookmark and Share

Mapping Fail with Entity Framework

While beginning a new project for myself, I decided to use the Entity Framework by building my entities first then creating the database required to support the entities I need. When I reached the stage where I had to map the relationships to the database, I wasn't exactly sure what to put in. I eventually figure out that I need to set the table mapping to the table with the many multiplicity, then set the tables to their corresponding keys in that table.

I originally set them to the same key before I looked at how the designer did it if you generated the edmx from the database. When I set the relationships to the correct keys, I kept receiving the following error:

Error 113: Multiplicity is not valid in Role in relationship X. Because the Dependent Role refers to the key properties, the upper bound of the multiplicity of the Dependent Role must be 1.

I kept twiddling with things, trying to get the error message to go away. It turned out that before you can change the column mapping, you have to click delete in the drop down before you can select another column and have it persist correctly. Also, for some reason, it really didn't like me editing the xml. Watch out for this if you prefer to create your entities before the database.

blog comments powered by Disqus

KodefuGuru.GetInfo()

Chris Eargle
LinkedIn Twitter Technorati Facebook

Chris Eargle
Telerik Developer Evangelist, C# MVP

JustCode

Telerik .NET Ninja

 

INETA Community Speakers Program

 

MVP - Visual C#

 

Friend of RedGate

World Map

Tag cloud

Month List

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer’s view in any way.