Print Page | Close Window

Many To Many Collection bug

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2312
Printed Date: 12-Oct-2025 at 10:42am


Topic: Many To Many Collection bug
Posted By: tersiusk
Subject: Many To Many Collection bug
Date Posted: 17-Nov-2010 at 2:39am
Hi 

I have found a possible bug in a Many To Many scenario. The following code throws the following exception. 
Violation of PRIMARY KEY constraint 'PK_SystemFunctions'. Cannot insert duplicate key in object 'dbo.SystemFunctions'.
I merely remove an entity and then add another entity and then add the removed enitity again. This is not suppose to trigger any inserts since the record was not deleted but only removed and added in memory. Also when I use only EF the error goes away and it works.
 var role = DemoDBEntities.DefaultManager.Roles.Where(r => r.Name == "RoleA").FirstOrDefault();

var remSystemfunction = role.SystemFunctions[0];

var systemFunctionToAdd = DemoDBEntities.DefaultManager.SystemFunctions.
                Where(sf => sf.Name == "SystemFunctionC").FirstOrDefault();

role.SystemFunctions.Remove(remSystemfunction);
role.SystemFunctions.Add(systemFunctionToAdd);
role.SystemFunctions.Add(remSystemfunction);

DemoDBEntities.DefaultManager.SaveChanges();
I have attached a sample project along with a sql file to generate the database and some dummy records.
uploads/988/ManyToManyBug.rar - uploads/988/ManyToManyBug.rar



Replies:
Posted By: sbelini
Date Posted: 17-Nov-2010 at 3:20pm
Hi tersiusk,
 
I verified the behavior you stated.
I am filing a bug an will follow up with you once the issue is fixed.
 
sbelini.


Posted By: tersiusk
Date Posted: 17-Nov-2010 at 11:00pm
Thanks, do you have any idea how long it will take to get this fixed?


Posted By: sbelini
Date Posted: 19-Nov-2010 at 9:04am
Hi Tersius,
 
The fix will be available in DevForce 6.0.7 which will be released early in December.



Print Page | Close Window