Wednesday 15 June 2011

sql server - Many-To-Many Cascading Delete Breeze -



sql server - Many-To-Many Cascading Delete Breeze -

i have 4 entities a, b, c, , d.

a has many bs , cs.

b has many ds.

and there many-to-many relationship between c , d.

this many-to-many relationship in bring together table exposed breeze entity cd.

i want found cascading delete deleting first entity in of next rows yields cascading delete.

a -> b -> d -> cd b -> d -> cd d -> cd -> c -> cd c -> cd

all other foreign keys have cascading delete except -> c. every time effort set cascading delete sql server 2012 gives me next error:

unable create relationship 'fk_dbo.c_dbo.a_aid'. introducing foreign key constraint 'fk_dbo.c_dbo.a_aid' on table 'c' may cause cycles or multiple cascade paths. specify on delete no action or on update no action, or modify other foreign key constraints. not create constraint. see previous errors.

how can resolve error , close i'm looking for?

as there multiple cascade paths, sql server complaining on delete cascade option

one path c->cd , c->a->b->d->cd

you can define foreign key out on delete cascade option

you can create insetad of delete trigger on table c , delete corresponding row in table a

sql-server entity-framework database-design ef-code-first breeze

No comments:

Post a Comment