cascade on delete in tables

Nov 5, 2009 at 3:14 PM

When I run the install project the cascade on delete foreign key in all tables  are not also updated.


thnks john 

Nov 13, 2009 at 8:34 PM

Cascade deletes are not implemented in the database. However, the cascade will happen if you load a model with the appropriate data and do a delete. Let me give an example.

Customer 1...N Order.

Lets say the customer_id in the order table does not allow null.

If you do the following in code


                Guid customerPkGuid = new Guid("35BF3565-F776-48a4-829D-E4F096C3E6E8");
                SubDomain sd = new SubDomain("Modifier");
                sd.AddSelectCommand(new CustomerSelectByPks(customerPkGuid));
                sd.AddSelectCommand(new OrderSelectByCustomerPks());

If you really need the relationships in the database to be created with cascade delete. Then the option at your disposal is to write another CreateData Script.
The database installer will run all createdata that are embedded in the project (Run Order is Alphabetical). So just create another file named CreateData_01.sql.
Set the build action to embedded resource. In this file you can write a script that ensures all relationships are cascading delete.