From 524690100e7dfd67f0ce12784d72563a450e5dcd Mon Sep 17 00:00:00 2001 From: Dan Bradley Date: Thu, 21 Apr 2016 09:52:51 +0100 Subject: [PATCH] Fix for foreign keys with same name to ensure that onupdate and ondelete are correct --- model/Database.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/model/Database.cs b/model/Database.cs index a991bc39..5d76df79 100644 --- a/model/Database.cs +++ b/model/Database.cs @@ -399,7 +399,7 @@ from INFORMATION_SCHEMA.TABLE_CONSTRAINTS DELETE_RULE, fk.is_disabled from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS rc - inner join sys.foreign_keys fk on rc.CONSTRAINT_NAME = fk.name"; + inner join sys.foreign_keys fk on rc.CONSTRAINT_NAME = fk.name and rc.CONSTRAINT_SCHEMA = OBJECT_SCHEMA_NAME(fk.parent_object_id)"; using (var dr = cm.ExecuteReader()) { while (dr.Read()) { var fk = FindForeignKey((string) dr["CONSTRAINT_NAME"], (string)dr["TABLE_SCHEMA"]);