I m using entity framework with 3.5 sp1, and I ve come across a strange problem. I have a 1 to many relationship and I cant seem to add a value for it.
I have a table "Bookings" and FK in table "Users" (nullable) and FK in table "BookingObjects"
so:
Users 0..1 <-> * Bookings * <-> 1 BookingObjects
Table: Users Entity: User Setname: Users
Table: Bookings Entity: Booking Setname: Bookings
Table: BookingObjects Entity: BookingObject Setname: BookingObjects
I have in my code:
b.UsersReference.EntityKey = new System.Data.EntityKey("BookingsystemEntities.Users", "UserID", 2);
b.BookingObjectsReference.EntityKey = new System.Data.EntityKey("BookingsystemEntities.Bookings", "BookingObjectID", 2);
b.BookingCreated = DateTime.Now;
(both values = 2 exists)
For some reason it gives error when I try to add value for BookingObjectsReference.EntityKey that says:
"You can not define the relationship because EntitySet name BookingsystemEntities.Bookings is not valid for her role in the association BookingObjects volume name BookingsystemEntities.FK_Bookings_BookingObjects." (I have swedish errors so I m not sure google translated correctly)
Not sure but shouldnt it be BookingsystemEntities.BookingObjects.FK_Bookings_BookingObjects? might be wrong there?
I have several 1 to many relations that works and I cant seem to find what is different with the FK_Bookings_BookingObjects one....
Do anyone have any ideas might be wrong here? I m running out of ideas, it all looks right
/M