views:

1335

answers:

2

Using VS 2010 beta 2, ASP.NET MVC.

I tried to create an Entity framework file and got the data from my database.

There were some issues with the relationships, so I started to tweak things around, but I kept getting the following error for simple one-to-one relationships

Error   1 Error 113: Multiplicity is not valid in Role 'UserProfile' in relationship 'FK_UserProfiles_Users'. 
Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.  myEntities.edmx 2024

My Users table is consists of some other many-to-many relationships to other tables, but when I try to make a one-to-one relationship with other tables, that error pops up.

Users Table

  • UserID
  • Username
  • Email

etc..

UserProfiles Table

  • UserProfileID
  • UserID (FK for Users Table)
  • Location
  • Birthday
+5  A: 

For one-to-one relationships, EF expects that the tables are using the same primary key. And really, if it's a true one-to-one they probably should. So in your example, if you make UserID the primary key on the UserProfiles table, your one-to-one will work.

Jacob Proffitt
So you mean all those primary keys in the child of a one-to-one mapping are useless...I guess my concept of table mapping needs fixing. Thanks.
Baddie
+1  A: 

Heh, I notice they haven't used that approach in the AdventureWorks DB - this screws up the employee/contact relationship ;)

CupcakeThief