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'm doing a port of a Linq2SQL code base over to Entity Framework Core and approaching this largely as a new user to EF Core. On the first app launch after getting things compiling again, I'm getting exceptions with my model that look like this:
My setup details aren't important, the issue here is the exception. What went wrong? All I can do is go check everything in every class on the model and hope it's right. In that stack we have useful info though. For example, Microsoft.EntityFrameworkCore.ModelBuilder.Entity(Type type) has the type we're building.
Proposal:
Could we catch exceptions in ModelBuilder.Entity(Type type) and wrap them (current exception being the .InnerException), outputting a much more useful error/message to the user? For example today I get:
Value cannot be null.
What if instead it said:
There was an error building the model with type 'StackOverflow.Models.Post': Value cannot be null.
We could get much more detailed, catching exceptions further up in the visitor and actually providing member information as well, laying out the exact type and member that had an issue. But even the type would be helpful as a quick improvement.
Thoughts?
The text was updated successfully, but these errors were encountered:
@NickCraver Could you file a new issue with a repro for the ArgumentNullException, since we would like to fix this.
For the idea here, we think it could be potential, but due to way conventions run it could be difficult to give valid and useful additional information.
Just run into a similar issue with this on .NET 5 / EF Core 5.x - getting NullReferenceException on ConfigureInverseNavigation. Was driving me nuts that I had no information in the stack trace that pointed at the issue!
I just tried updating the EF packages to .NET 6 (preview) and tried again. This time we get more usable information:
Message:
Test method TestContext.AnvilFGDEV_Test.ReadTablesAsync threw exception:
System.Collections.Generic.KeyNotFoundException: The given key 'System.Nullable`1[System.Decimal] CPSChargePartner' was not present in the dictionary.
I'm doing a port of a Linq2SQL code base over to Entity Framework Core and approaching this largely as a new user to EF Core. On the first app launch after getting things compiling again, I'm getting exceptions with my model that look like this:
Text version:
Further technical details
EF Core version: 2.1.2
My setup details aren't important, the issue here is the exception. What went wrong? All I can do is go check everything in every class on the model and hope it's right. In that stack we have useful info though. For example,
Microsoft.EntityFrameworkCore.ModelBuilder.Entity(Type type)
has the type we're building.Proposal:
Could we catch exceptions in
ModelBuilder.Entity(Type type)
and wrap them (current exception being the.InnerException
), outputting a much more useful error/message to the user? For example today I get:What if instead it said:
We could get much more detailed, catching exceptions further up in the visitor and actually providing member information as well, laying out the exact type and member that had an issue. But even the type would be helpful as a quick improvement.
Thoughts?
The text was updated successfully, but these errors were encountered: