1

I started to get this error after marking an ID column on an entity with DatabaseGeneratedOption.Identity (for some reason EF didn't know it was an identity column and was trying to insert a value on that column).

I found this question: A dependent property in a ReferentialConstraint is mapped to a store-generated column.

However, as far as I can tell, all of my relations are perfectly fine. I checked every single table, and triple checked the tables related to the one on which I added the DatabaseGeneratedOption.Identity to. Even odder, the column mentioned in the error is 'ID' - I don't have any foreign keys where the dependent column is ID. I checked this using the following query, which returned no column named 'ID':

SELECT Tab.TABLE_NAME, Col.Column_Name from 
    INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab, 
    INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col 
WHERE 
    Col.Constraint_Name = Tab.Constraint_Name
    AND Col.Table_Name = Tab.Table_Name
    AND Constraint_Type = 'FOREIGN KEY '

Is there anyway to determine which table has the offending foreign key, if indeed it exists? Is there a query I can run to determine if a column marked as 'Identity' is also the dependent column in a foreign key relationship?

Community
  • 1
  • 1
Stephen Panzer
  • 289
  • 5
  • 16

0 Answers0