Skip to content

Commit 870012d

Browse files
mikaelweaveardalis
authored andcommitted
Adding protected parameterless constructor so SmartEnums are supported by EF (#16)
1 parent d35d938 commit 870012d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/SmartEnum.UnitTests/TestEnum.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,10 @@ public class TestEnum : SmartEnum<TestEnum, int>
1111
protected TestEnum(string name, int value) : base(name, value)
1212
{
1313
}
14+
15+
private TestEnum() : base()
16+
{
17+
// required for EF
18+
}
1419
}
1520
}

src/SmartEnum/SmartEnum.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ protected SmartEnum(string name, TValue value)
3939
Value = value;
4040
}
4141

42+
protected SmartEnum()
43+
{
44+
// Required for EF
45+
}
46+
4247
public static TEnum FromName(string name)
4348
{
4449
Guard.Against.NullOrEmpty(name, nameof(name));

0 commit comments

Comments
 (0)