0

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.

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Ok so two questions, if it's got nothing to do with DateTimeFormatInfo.AbbreviatedDayNames, why is it mentioning it in the error message. That property is a String[] but why give the name? Secondly is there any tool which shows the mapping and mapping validation issues in a clear way?
I am not sure why exactly you get this info with DayNames. I justed tested Entity with 'String[] SomeArray' and got the error: "The property 'Party.SomeArray' 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." So in my case 'SomeArray' is the name of the Property itself. There is probably something specific about the situation you have.
That's what I'm trying to find out, where exactly the AbbreviatedDayNames property is sitting, on which of my entities. Like I said I have a lot and a text search doesn't locate this property. I realise that the error is in mapping string[] but I am having trouble finding it, hence the request for some tool or easier way.
Assuming you have a folder Entities where all the entities are, can't you just search all files in that folder looking for 'string[]'.
I have searched for multiple versions of string[] with no luck. While I agree with you that the second part of the error refers to string[], the first part is DateTimeFormatInfo.AbbreviatedDayNames which I can not find. All that aside My original question still stands if there is a tool to better analyse the entities and mappings then just looking at the exception.
0

I experienced the exact same error as above migrating an application to Entity Framework core as well just now

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'."

In my case the issue was related to an entity with a CultureInfo property Type.

System.Globalization.CultureInfo.DateTimeFormat is a DateTimeFormatInfo type and is the Property the error was describing in my case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.