I'm using LINQ to SQL in project. I'm using DataContext.CreateDatabase() approach to create database.
There's one Master table getting ID as OK
Other tables are mentioning for this ID as FK. I've set the Update and Remove role to Cascade in FK. So whenever record from master table is taken away all of the referencing records are instantly taken off all child tables..
Basically remove database and begin my application which inspections the presence of database at launch. It produces database effective. But issue is in produced FK. Update and Remove role are going to No Action rather than Cascade.. Due to this i must change all of the FK Update and Remove specs to Cascade by hand
Does anybody facing this issue? What's the solution?
You should use
DeleteOnNull=true to do deletions on Association's.
DeleteOnNull is not quite exactly the same factor as cascade on remove because this deletion is completed in c# code and never within the database - check this out blog for particulars http://blogs.msdn.com/b/dinesh.kulkarni/archive/2008/05/11/linq-to-sql-tips-4-use-deleteonnull-if-you-want-to-delete-object-with-null-fk.aspx