I encountered a problem when using Entity Developer version 6.7.965 to work with EF Core 3.0 on the .NET Framework (using the Model-First approach)
The problem is this:
I have a complex type AddressPart containing two fields: Name and TypeName.
I also have one more complex type Address, which contains several fields of type AddressPart: City, Street, House.
I am adding the InvoiceAddress property of the Address complex type to the Invoice entity.
The result is the following class diagram:
- Invoice
- InvoiceAddress
- City
- Name
TypeName
- Name
- Street
- Name
TypeName
- Name
- House
- Name
TypeName
- Name
- City
- InvoiceAddress
The problem arises at the stage of mapping the properties of a nested complex type to columns in the database.
I use the following settings to map complex type properties:
%parent property name%_%property name%
Thus, I expect the column names to be formed as follows:
- Invoice
- InvoiceAddress
- City
- Name - InvoiceAddress_City_Name
TypeName - InvoiceAddress_City_TypeName
- Name - InvoiceAddress_City_Name
- Street
- Name - InvoiceAddress_Street_Name
TypeName - InvoiceAddress_Street_TypeName
- Name - InvoiceAddress_Street_Name
- House
- Name - InvoiceAddress_House_Name
TypeName - InvoiceAddress_House_TypeName
- Name - InvoiceAddress_House_Name
- City
- InvoiceAddress
- Invoice
- InvoiceAddress
- City
- Name - InvoiceAddress_Name
TypeName - InvoiceAddress_TypeName
- Name - InvoiceAddress_Name
- Street
- Name - InvoiceAddress_Name
TypeName - InvoiceAddress_TypeName
- Name - InvoiceAddress_Name
- House
- Name - InvoiceAddress_Name
TypeName - InvoiceAddress_TypeName
- Name - InvoiceAddress_Name
- City
- InvoiceAddress
Thus, I get many errors saying that different properties use the same column in the database.
The problem can be solved by writing a mapping for each field manually at the level of a specific entity, however, there are a lot of entities using this complex type.
The question is, is there a way to adjust mapping at the level of the complex type or model settings so that it is not necessary to manually configure this at the level of each entity?
I tried to configure the mapping on the level of City, Street and House properties, however the mapping settings overwrite each other.
I also tried to find the similarity of the keyword %parent property name% for the complex type, but apparently it does not exist