-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Model.Validate errors do not indicate the specific property affected by misconfiguration/validation errors #17010
Comments
@rbarna1 The exception message for this case has been improved in 3.0--see #12894. It now has the form:
Does this address your issue? |
I'm not sure, but my initial thought is no. The problem isnt one of constructors, since the type is Uri, not a custom class. The original problem is lack of serialization configuration on a property on one of our POCOs that happens to be of type Uri. My issue here is the error simply pointing to Uri (which we have many of). |
I have a similar issue, where entity type is 'string' and I am working on a tool to auto-generate entity framework code. It is very difficult to locate the 'string' in a very large auto-generated code base. Using
Question is where is this? It would be nice to know which class has this problematic property. BTW, is there an easy way to debug dotnet ef tools? I guess it spawns child processes which makes it difficult to attach a debugger. Thanks, |
@rbarna1 Please post a small, runnable project/solution or complete code listing that shows how to generate the exception you are seeing. That way I can join the dots of what the issue is in the model to the exception message you are seeing. |
@orcun Mapping |
We could add the path that model building took to discover an entity type if we implemented Configuration layering |
@AndriySvyryd issue seems to be the same as mine. I dont think his ENTITY is a string...its the string property that he has misconfigured that he's having a hard time finding from the stack trace. if (constructorBindingList.Count == 0)
{
IEnumerable<string> values = source.SelectMany<IEnumerable<ParameterInfo>, ParameterInfo>((Func<IEnumerable<ParameterInfo>, IEnumerable<ParameterInfo>>) (f => f)).GroupBy<ParameterInfo, ConstructorInfo>((Func<ParameterInfo, ConstructorInfo>) (f => f.Member as ConstructorInfo)).Select<IGrouping<ConstructorInfo, ParameterInfo>, string>((Func<IGrouping<ConstructorInfo, ParameterInfo>, string>) (x => CoreStrings.ConstructorBindingFailed((object) string.Join("', '", x.Select<ParameterInfo, string>((Func<ParameterInfo, string>) (f => f.Name))), (object) (Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions.DisplayName(entityType) + "(" + string.Join(", ", ((IEnumerable<ParameterInfo>) x.Key.GetParameters()).Select<ParameterInfo, string>((Func<ParameterInfo, string>) (y => y.ParameterType.ShortDisplayName() + " " + y.Name))) + ")"))));
throw new InvalidOperationException(CoreStrings.ConstructorNotFound((object) Microsoft.EntityFrameworkCore.Metadata.Internal.EntityTypeExtensions.DisplayName(entityType), (object) string.Join("; ", values)));
}``` |
Notes from triage: putting this on the backlog as something we can improve if we implement #15898 first. One way to debug these kinds of issues is to look at the model that EF has built before it is validated. For example, put a breakpoint at the end of OnModelCreating, and then inspect This can then be used to find out which types are configured as entity types as well as where they are referenced from. |
This has been an issue several times for us. We have a reasonably complex POCO based data model. Several base types are re-used across our models, and many of our POCOs include Uri properties (though this could affect other framework types).
When creating new top-level entities we often hit mis-configurations of our child properties. These are legitimate misconfigurations of the Uri (they often need HasConfiguration to configure their serialization) based on the functionality of EF Core. Our problem isn't with the error itself.
The problem is that the error does not include the path to the specific affected property. It would be VERY helpful if errors of this type pointed to the specific instance of the Uri (or other framework type) that has validation/configuration errors.
Stack trace:
Steps to reproduce
Create a POCO for a DbSet where the DbSet object type has child properties with Uri properties. When trying to add a migration (e.g.:
dotnet ef migrations add someMigration--context MyModelPostgresContext
), note that this will require Uri property configuration, but the error will not point to the specific property.Further technical details
EF Core version: 2.2
Database Provider: NpgSql for Postgres
Operating system: Win 10
IDE: Visual Studio 2019 16.1
The text was updated successfully, but these errors were encountered: