Entity Framework Core - Debugging Mapping

c# entity-framework entity-framework-core


I have an existing database and an existing domain, it was originally created and accessed using nHibernate and am now moving it to Entity Framework Core.

I've started by trying to access just one element of the domain (which is unfortunately tightly-coupled with a lot of other entities). The domain is very legacy and monolithic and can NOT be modified as part of this exercise.

I get a lot of errors similar to: "The property 'DateTimeFormatInfo.AbbreviatedDayNames' could not be mapped, because it is of type 'String[]' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'."

.NET type mapping aside, it's very difficult to try and figure where exactly the mapping is failing. Is there a tool or way of easily identifying the failing section.

I have tried the following: - SQL Trace, nothing as it fails in the app. - Exception just gives that error, no inner exception or further information. - Did a text search in the entire solution for entities with elements of type of 'DateTimeFormatInfo'. There are none. - Did a text search in entire solution for entities including or using property/function AbbreviatedDayNames, also nothing.

I'm therefore stuck trying to locate exactly which entity mapping is failing.

Additionally I'm eager to use the EF Fluent API for any mapping.

6/2/2017 3:16:02 PM

Popular Answer

You have be searching for the wrong text.
DateTimeFormatInfo.AbbreviatedDayNames is not a Property. You should instead try find any Properties with type 'String[]', so search for that in Entites.
And the error itself says where the problem is. EF can't map array of string to any db type.

6/2/2017 3:46:49 PM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow