Skip to content

Commit a956b75

Browse files
committed
try to fix problem with many fields with same enum type
1 parent 9441d89 commit a956b75

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

samples/SpatialFocus.EntityFrameworkCore.Extensions.SQLiteDemo/Entities/Product.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public Product()
2424

2525
public ProductCategory ProductCategory { get; set; }
2626

27+
public ProductCategory ProductCategorySecondField { get; set; }
28+
2729
public int ProductId { get; set; }
2830

2931
public DateTime ReleaseDate { get; set; }

src/SpatialFocus.EntityFrameworkCore.Extensions/EnumLookupExtension.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace SpatialFocus.EntityFrameworkCore.Extensions
77
{
88
using System;
9+
using System.Collections.Generic;
910
using System.Linq;
1011
using Microsoft.EntityFrameworkCore;
1112
using Microsoft.EntityFrameworkCore.Metadata;
@@ -82,10 +83,21 @@ public static void ConfigureEnumLookup(this ModelBuilder modelBuilder, EnumLooku
8283
})
8384
.ToArray();
8485

86+
if (!ConcreteTypeSeededList.Contains(concreteType))
87+
{
88+
ConcreteTypeSeededList.Add(concreteType);
89+
}
90+
else
91+
{
92+
continue;
93+
}
94+
8595
enumLookupBuilder.HasData(data);
8696
}
8797
}
8898

99+
private static List<Type> ConcreteTypeSeededList { get; set; } = new List<Type>();
100+
89101
private static Type GetEnumOrNullableEnumType(this Type propertyType)
90102
{
91103
if (!propertyType.IsEnumOrNullableEnumType())

0 commit comments

Comments
 (0)