Hierarchy Inheritance Entity Framework Table

c# entity-framework wpf

Question

I'm attempting to implement table-per-hierarchy inheritance with some of my database tables, like asAddress . I want to create three classes usingAddress which areEmployeeAddress , CustomerAddress , SupplierAddress .

+-------------------+------------------------+
| Address           |> EmployeeAddress       |
+-------------------+------------------------+
| ID                | ..                     |
| OwnerID           | EmployeeID             |
| OwnerCategory     | (condition: where = 0) |
| Street_1          | ..                     |
| Street_2          | ..                     |
| City              | ..                     |
| Province          | ..                     | 
| PostalCode        | ..                     |
+-------------------+------------------------+
                    |> CustomerAddress       |
                    +------------------------+
                    | ..                     |
                    | EmployeeID             |
                    | (condition: where = 1) |
                    | ..                     |
                    | ..                     |
                    | ..                     |
                    | ..                     | 
                    | ..                     |
                    +------------------------+
                    |> SupplierAddress       |
                    +------------------------+
                    |  ..                    |
                    | EmployeeID             |
                    | (condition: where = 2) |
                    | ..                     |
                    | ..                     |
                    | ..                     |
                    | ..                     | 
                    | ..                     |
                    +------------------------+

The issue is that I constantly experiencing errors.

When Address Its concrete and includesOwnerCategory property:

Error 3032: Problem in mapping fragments starting at line 178:Condition member 'addresses.OwnerCategory' with a condition other than 'IsNull=False' is mapped. Either remove the condition on addresses.OwnerCategory or remove it from the mapping.

When Address is abstract, which includes theOwnerCategory property:

Problem in mapping fragments starting at line 178:Condition member 'addresses.OwnerCategory' with a condition other than 'IsNull=False' is mapped. Either remove the condition on addresses.OwnerCategory or remove it from the mapping.

When Address is concrete, whereas has not includes theOwnerCategory property:

'DtcInvoicer.Database.Address' does not contain a definition for 'OwnerCategory' and no extension method 'OwnerCategory' accepting a first argument of type 'DtcInvoicer.Database.Address' could be found (are you missing a using directive or an assembly reference?)

and

Problem in mapping fragments starting at lines 177, 195:EntityTypes Model.Address, Model.EmployeeAddress are being mapped to the same rows in table addresses. Mapping conditions can be used to distinguish the rows that these types are mapped to.

(The condition (when OwnerCategory = 0) is already set.

When Address include the abstract and has notOwnerCategory property:

'DtcInvoicer.Database.Address' does not contain a definition for 'OwnerCategory' and no extension method 'OwnerCategory' accepting a first argument of type 'DtcInvoicer.Database.Address' could be found (are you missing a using directive or an assembly reference?)

Thank you in advance for any assistance.

1
7
9/1/2011 3:48:54 PM

Accepted Answer

given that you areOwnerCategory It cannot be mapped to a property under the circumstances of your inheritance. Additionally, it seems that you need to haveAddress abstract is selected. Make sure the property is removed from your model and that you change any code that used it. Make careful to address those places since the non-mapping problems you mentioned seem to be the compiler's default error when it can't locate a certain member.

9
9/1/2011 3:54:58 PM


Related Questions





Related

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