Entity Framework mant to many insert
- by Jacob
I've been playing around with Entity Framework v2 and added some code to insert new entity with many to many relationship , lets say this entity is called meeting.
I add hours to meeting :
meeting.Hours.Add(hour);
and I get different errors on different occasions
On Update :
Cannot insert the value NULL into column 'Meetings_Id', table 'Plan.dbo.MeetingHour'; column does not allow nulls. INSERT fails.
The statement has been terminated.
On Inset :
An item with the same key has already been added.
But the tricky party is that if I add this manually trough SQL Server Management Studio , I can update the entity with the same value , clearing it first (meeting.Hour.Clear())
Can't see what could be the problem , maybe entity model isn't mapped correctly ?