EF6 always FK exception after delete a row that cause FK exception

entity-framework-6

Accepted Answer

ZZZ_tmp
0
10/2/2018 10:46:47 AM

Popular Answer

The id city column of a person record must refer to a valid record in the city database, and with the default settings, this will always result in an exception.

To remedy this

  1. the person.id city field be modified to accept null values
  2. Make "on delete set null" the foreign key definition instead.

This presupposes that you do not want to erase a person's record just because a city has been deleted.

https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-table-constraint-transact-sql?view=sql-server-2017



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow