Skip to content

Commit b35c2f5

Browse files
committed
Using the GetTableName() extension method to obtain the name of the table, used in the index name.
1 parent 7afbca0 commit b35c2f5

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

SQLite.CodeFirst/Builder/CreateIndexStatementBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public CreateIndexStatementCollection BuildStatement()
3131
foreach (var index in indexAnnotations.SelectMany(ia => ia.Indexes))
3232
{
3333
CreateIndexStatement createIndexStatement;
34-
string indexName = GetIndexName(entityType, edmProperty, index);
34+
string indexName = GetIndexName(index, edmProperty);
3535
if (!createIndexStatments.TryGetValue(indexName, out createIndexStatement))
3636
{
3737
createIndexStatement = new CreateIndexStatement

SQLite.CodeFirst/Convention/SqliteForeignKeyIndexConvention.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System;
1+
using SQLite.CodeFirst.Extensions;
2+
using System;
23
using System.Collections.Generic;
34
using System.ComponentModel.DataAnnotations.Schema;
45
using System.Data.Entity.Core.Metadata.Edm;
@@ -52,7 +53,7 @@ public virtual void Apply(AssociationType item, DbModel model)
5253
var foreignKeyIndicies = annotation.Indexes.Where(index => index.Name == "IX_" + edmProperty.Name);
5354
foreach (var foreignKeyIndex in foreignKeyIndicies)
5455
{
55-
var indexAttribute = new IndexAttribute(string.Format("IX_{0}_{1}", item.Constraint.ToRole.Name, edmProperty.Name));
56+
var indexAttribute = new IndexAttribute(string.Format("IX_{0}_{1}", item.Constraint.ToRole.GetEntityType().GetTableName(), edmProperty.Name));
5657
IndexAnnotation foreignKeyIndexAnnotation = new IndexAnnotation(indexAttribute);
5758
newIndexAnnotation = (IndexAnnotation)newIndexAnnotation.MergeWith(foreignKeyIndexAnnotation);
5859
}

0 commit comments

Comments
 (0)