You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have just upgraded a large project to .NET 9. All seems to work well, except for our test suite that works on the InMemory provider. For all entities that have a non-nullable enum, an exception is thrown when an entity is added DbSet.Add(). It does not matter which entity or which DbSet, as long as it is an enum, and that it is required (non-nullable). This is where the exception is thrown:
As can be seen, the TypeMapper.Converter for my enum is null, but the forced null forgiving ! makes me believe it was very unexpected for it to be null at this point.
I have created a minimal repro to try to get the same error in a freshly created .NET 9 project, but it does not (of course) crash there. This leads me to believe something I've done wrong upgrading the .NET 8 project to .NET 9. Please help me point out how I can debug this. I have invested in thousands of InMemory tests and would be sad to have to let them go.
Workaround: If I change my enum to be nullable, the test will run successfully. So it is only for non-nullable enum properties it fails.
Your code
This repro works fine, but demonstrates what is not working in my real project.
I do have a compiled model, but I also tried commenting out .UseModel() when constructing the InMemory. I remember this was necessary in .NET 8, but it seems .NET 9 picks up the model anyway without the .UseModel() call?
When I deleted the Model folder entirely, the problem went away. I will do some verification to see if I can live without the compiled model. .NET 9 seems faster overall initially during my testing.
Bug description
I have just upgraded a large project to .NET 9. All seems to work well, except for our test suite that works on the InMemory provider. For all entities that have a non-nullable enum, an exception is thrown when an entity is added DbSet.Add(). It does not matter which entity or which DbSet, as long as it is an enum, and that it is required (non-nullable). This is where the exception is thrown:
As can be seen, the TypeMapper.Converter for my enum is null, but the forced null forgiving ! makes me believe it was very unexpected for it to be null at this point.
I have created a minimal repro to try to get the same error in a freshly created .NET 9 project, but it does not (of course) crash there. This leads me to believe something I've done wrong upgrading the .NET 8 project to .NET 9. Please help me point out how I can debug this. I have invested in thousands of InMemory tests and would be sad to have to let them go.
Workaround: If I change my enum to be nullable, the test will run successfully. So it is only for non-nullable enum properties it fails.
Your code
This repro works fine, but demonstrates what is not working in my real project.
Main differences from real project;
Stack traces
Verbose output
EF Core version
9.0.1
Database provider
InMemory
Target framework
.NET 9
Operating system
No response
IDE
No response
The text was updated successfully, but these errors were encountered: