Friday, 15 April 2011

c# - Entity Framework 6 : Given multiplicity constraints, a corresponding 'CProperty' must also in the 'Deleted' state -



c# - Entity Framework 6 : Given multiplicity constraints, a corresponding 'CProperty' must also in the 'Deleted' state -

i tried next code next designed model. first phone call savechanges() succeed not when comes sec call.

i have worked 18 hours on , can't figure out problem. specially when can accomplish code goal manually mssql server explorer !

can provide me solution ?

var mc = new model1container1(); mc.categories.add(new category() { text = "laptop" }); mc.categories.add(new category() { text = "tv" }); mc.savechanges(); var cat = mc.categories.where(c => c.text == "laptop").firstordefault(); ckey ck = new ckey() { key = "ram" }; cat.ckeys.add(ck); (int = 1; < 100; i++) { var ia = new item() { text = "msi gx780-r", category = cat }; ia.cproperties.add(new cproperty() { value = "4gb", ckey = ck }); mc.items.add(ia); mc.savechanges(); }

you trying associate same ckey instance 100 instances of cproperty, according graph of multiplicities, given instance of ckey can associated @ 1 cproperty.

either create new instance of ckey in each iteration of loop, or modify schema.

c# .net sql database-design

No comments:

Post a Comment