Entity Framework mant to many insert

Posted by Jacob on Stack Overflow See other posts from Stack Overflow or by Jacob
Published on 2010-03-25T20:30:54Z Indexed on 2010/03/25 20:33 UTC
Read the original article Hit count: 413

Filed under:
|
|
|

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 ?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about c#