Problem with m:n relationship with Entity Framework
Posted: Thu 19 Jun 2008 17:57
Hello,
I'm wondering if there are any known issues with the ADO.Net Entity Framework and MyDirect.Net. I have a simple scenario:
Tables: Manufacturers -->Mfgaddress--> Addresses.
Entity Objects: Manufacturs has an EntityCollection of Addresses. If I create a new Manufacturer, add a single new Address to it, and use the Entity Context like so:
ctx.AddToManufacturers(m);
int affected = ctx.SaveChanges();
Then I get:
---- CoreLab.MySql.MySqlException : Cannot add or update a child row: a foreign key constraint fails (`audioland/mfgaddress`, CONSTRAINT `FK_mfg` FOREIGN KEY (`manufacturerid`) REFERENCES `manufacturers` (`ManufacturerId`))
It would seem that it's trying to create the in-between relationship table before it should?
I'm wondering if there are any known issues with the ADO.Net Entity Framework and MyDirect.Net. I have a simple scenario:
Tables: Manufacturers -->Mfgaddress--> Addresses.
Entity Objects: Manufacturs has an EntityCollection of Addresses. If I create a new Manufacturer, add a single new Address to it, and use the Entity Context like so:
ctx.AddToManufacturers(m);
int affected = ctx.SaveChanges();
Then I get:
---- CoreLab.MySql.MySqlException : Cannot add or update a child row: a foreign key constraint fails (`audioland/mfgaddress`, CONSTRAINT `FK_mfg` FOREIGN KEY (`manufacturerid`) REFERENCES `manufacturers` (`ManufacturerId`))
It would seem that it's trying to create the in-between relationship table before it should?