Closed frankfajardo closed 2 years ago
@frankfajardo Please attach a small, runnable project or post a small, runnable code listing that reproduces what you are seeing so that we can investigate.
Hi @ajcvickers , I will close this issue. We have multiple relationships between our two entities (Product and Tag entities) similar to this SO question which was okay with EFCore5 but not with EFCore6.. So we have added configuration in our OnModelCreating()
. We can live with that.
Question: What is causing the NullReferenceException?
We have an active project which was started on ASP.NET 5 and EFCore 5.0. I'm investigating the move/migration to ASP.NET 6 and EFCore 6.0. The move to ASP.NET 6 (with EFCore 5.0) appears to be okay; the app is building and our tests are all passing still. But the move to EFCore 6.0 seems to be more challenging. II understand there are breaking changes between EFCore 5 and EFCore 6. However, I'm encountering this runtime error which I could not figure out the cause of. If only it gives me more info.
It is failing at this:
The entity model
Product
is this:Running the test in debug mode, the data being saved has this (minimal) test data:
What is causing the NullReferenceException? I already tried to assign values to all nullable properties of the
Product
entity but it still complains. I was only running one specific test so I don't think a shared dbContext is an issue. Besides, the unit test class creates its own instance of the dbContext.The same test runs without failure on EFCore 5.
I have re-generated our migration scripts using the
dotnet-ef 6.0.0
but I get same results.EF Core version: 6.0 Database provider: InMemory, Postgresql Target framework: .NET 6.0 Operating system: Windows 11 IDE: Visual Studio 2022