I have created a database through Entity Framework Code First Approach and My application is ready and running live . The problem is that I did not turned "False" on Cascade Delete at the time of creating database. Now if I delete any record from one table that is referenced with another table through foreign so all the record containing foreign key of deleted row is deleted from another table . Practically demonstration :
Let say I have a Table called Passenger:
ID Name CategoryID
1 ABC 1
CategoryID here is a foreign key
Here is the category Table
ID Name
1 Gold
Let say I run my query on category table
delete from Category where ID = 1
Now all the record from my Passenger Table is deleted . I want to restrict it. Is it Possible through SQL now ?
Category
table, let sayActive
, then useUpdate
statement. For example:UPDATE Category Set Active = 'false'
– Maciej Los May 11 '18 at 6:51