Skip to content

Commit 4e894e1

Browse files
author
Filipe GP
authored
Merge pull request #1 from OlivierBouchoms/master
Exclude discriminators (inheritance) from being encrypted
2 parents d17c0ae + 936d6eb commit 4e894e1

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/EntityFrameworkCore.DataEncryption/ModelBuilderExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static void UseEncryption(this ModelBuilder modelBuilder, IEncryptionProv
2626
{
2727
foreach (IMutableProperty property in entityType.GetProperties())
2828
{
29-
if (property.ClrType == typeof(string))
29+
if (property.ClrType == typeof(string) && !IsDiscriminator(property))
3030
{
3131
object[] attributes = property.PropertyInfo.GetCustomAttributes(typeof(EncryptedAttribute), false);
3232

@@ -36,5 +36,10 @@ public static void UseEncryption(this ModelBuilder modelBuilder, IEncryptionProv
3636
}
3737
}
3838
}
39+
40+
private static bool IsDiscriminator(IMutableProperty property)
41+
{
42+
return property.Name == "Discriminator" && property.PropertyInfo == null;
43+
}
3944
}
4045
}

0 commit comments

Comments
 (0)