-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Sentinel not generated for enums on Optimize-DbContext #30832
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I tested this last week and it was fixed. But the release today reintroduced/reverted the same problem. |
@rgordey What do you mean by, "But the release today?" What version number? |
@ajcvickers 8.0.0-preview.5.23265.4 |
@ajcvickers I'm not able to reproduce this. With that build, I see the following code generated: var status = runtimeEntityType.AddProperty(
"Status",
typeof(OrderStatus),
propertyInfo: typeof(Blog).GetProperty("Status", BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly),
fieldInfo: typeof(Blog).GetField("<Status>k__BackingField", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly),
sentinel: (OrderStatus)0); Can you post a small, complete project with a model that reproduces what you are seeing? |
I will spin up a sample today. I suspect it has to do with one convention I am using to save enums as the string value. protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder)
{
configurationBuilder.Properties<Enum>()
.HaveConversion<string>()
.HaveMaxLength(50);
configurationBuilder.Properties<string>()
.HaveMaxLength(100);
configurationBuilder.Properties<decimal>()
.HavePrecision(18, 2);
} |
I figured out my problem while trying to make a sample. I had the [Flags] attribute on the enum. But did not have a 0 value assigned. |
For about the last week, every release of EF Core Preview has had the same result...
Include provider and version information
EF Core version: 8.0.0-preview.5.23254.6
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 8.0
Operating system: Windows 11
IDE: Visual Studio 2022 17.6
The text was updated successfully, but these errors were encountered: