From 066dc77bec051b83d37b1456cd4cd271d5668ce6 Mon Sep 17 00:00:00 2001 From: ErikEJ Date: Wed, 2 Dec 2015 19:28:38 +0100 Subject: [PATCH] Only get NONCLUSTERED and CLUSTERED indexes from sys.indexes to avoid name being NULL and also ignore other irrelevant index types https://msdn.microsoft.com/da-dk/library/ms173760.aspx Fixes some issues reported in #3861 --- .../SqlServerDatabaseModelFactory.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EntityFramework.MicrosoftSqlServer.Design/SqlServerDatabaseModelFactory.cs b/src/EntityFramework.MicrosoftSqlServer.Design/SqlServerDatabaseModelFactory.cs index 8148eda5149..162446ab9c2 100644 --- a/src/EntityFramework.MicrosoftSqlServer.Design/SqlServerDatabaseModelFactory.cs +++ b/src/EntityFramework.MicrosoftSqlServer.Design/SqlServerDatabaseModelFactory.cs @@ -214,6 +214,7 @@ FROM sys.indexes i INNER JOIN sys.columns c ON ic.object_id = c.object_id AND c.column_id = ic.column_id WHERE object_schema_name(i.object_id) <> 'sys' AND i.is_primary_key <> 1 + AND i.type IN (1,2) AND object_name(i.object_id) <> '" + HistoryRepository.DefaultTableName + @"' ORDER BY object_schema_name(i.object_id), object_name(i.object_id), i.name, ic.key_ordinal";