Table per Concrete Type Inheritance and Associations
Table per Concrete Type Inheritance and Associations
Hi,
One of the main reasons for choosing to evaluate Entity Developer is its ability to handle Table per Concrete Type Inheritance (TPC) and of course its Model First approach. I have managed to actually create a model from scratch, correctly define TPC and map it to the database! Excellent up until now.
Now, in one of my inherited classes I want to define an association. Notice that this association should be specific to the inherited class and not to the base class. The problem is that when trying to do so, Entity Developer does not allow it showing the message: "Parent class should have entity key". Obviously the designer does not recognise that the entity key belongs to the base class...
Is there a workaround for defining the association?
I should note that the version I'm using is the "Entity Developer 3.00 Standard Trial" (v. 3.0.60)...
Thanks,
Kostas
One of the main reasons for choosing to evaluate Entity Developer is its ability to handle Table per Concrete Type Inheritance (TPC) and of course its Model First approach. I have managed to actually create a model from scratch, correctly define TPC and map it to the database! Excellent up until now.
Now, in one of my inherited classes I want to define an association. Notice that this association should be specific to the inherited class and not to the base class. The problem is that when trying to do so, Entity Developer does not allow it showing the message: "Parent class should have entity key". Obviously the designer does not recognise that the entity key belongs to the base class...
Is there a workaround for defining the association?
I should note that the version I'm using is the "Entity Developer 3.00 Standard Trial" (v. 3.0.60)...
Thanks,
Kostas
I have prepared a simple model in Entity Developer, but I cannot seem to find a way to attach it to this message.
Anyway, the way to reproduce the error is to create a model with two classes implementing a Table Per Concrete Type inheritance strategy, add a third class and try to add an association between the second class (inherited) and the third one. The designer will not allow you to do that.
I workaround that has worked for me is to edit the edmx file with an XML editor and manually configure the association. Of course that beats the point of having a designer on the first place...
Anyway, the way to reproduce the error is to create a model with two classes implementing a Table Per Concrete Type inheritance strategy, add a third class and try to add an association between the second class (inherited) and the third one. The designer will not allow you to do that.
I workaround that has worked for me is to edit the edmx file with an XML editor and manually configure the association. Of course that beats the point of having a designer on the first place...
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
We are also evaluating the product and the purchase decision is at 90% right now.kkara wrote:I workaround that has worked for me is to edit the edmx file with an XML editor and manually configure the association. Of course that beats the point of having a designer on the first place...
Is there a patch to solve this?
kkara, can you provide some details about the workaround?
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
It is ok now.
UPDATE: not working 100% right now and exchanging same emails with support.
---
It was solved with one of the latest releases. Currently I'm using the lastest beta.
---
It was solved with one of the latest releases. Currently I'm using the lastest beta.
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
Solved
First I would like to give thanks to the great effort for the support guys. Thank you for the step-by-step instructions:
1. Create the model via the wizard.
2. Remove the associations between Provider and *Providers (from the conceptual part only).
3. Remove the discriminator property ('Type') from the base class ('Provider').
4. Make the base class abstract.
5. Create interim classes (*ProviderBase) and derive (with the TPH inheritance) them from the base class.
6. Map interim classes to the Providers table (in the 'Mapping Details' dialog, select dbo.Providers), and add the discriminator conditions (e.g., 'Type = 1' for DomainProviderBase and 'Type = 2' for DnsProviderBase).
7. Derive (with the TPT inheritance) *Provider classes from the corresponding *ProviderBase classes.
8. Remove the key properties ('ProviderId') from the *Provider entity classes.
9. Map the ProviderId column in the *Provider classes: in the 'Mapping Details' dialog, select the ProviderId property from the drop-down list near the ProviderId column.
1. Create the model via the wizard.
2. Remove the associations between Provider and *Providers (from the conceptual part only).
3. Remove the discriminator property ('Type') from the base class ('Provider').
4. Make the base class abstract.
5. Create interim classes (*ProviderBase) and derive (with the TPH inheritance) them from the base class.
6. Map interim classes to the Providers table (in the 'Mapping Details' dialog, select dbo.Providers), and add the discriminator conditions (e.g., 'Type = 1' for DomainProviderBase and 'Type = 2' for DnsProviderBase).
7. Derive (with the TPT inheritance) *Provider classes from the corresponding *ProviderBase classes.
8. Remove the key properties ('ProviderId') from the *Provider entity classes.
9. Map the ProviderId column in the *Provider classes: in the 'Mapping Details' dialog, select the ProviderId property from the drop-down list near the ProviderId column.
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
-
- Posts: 10
- Joined: Fri 11 Feb 2011 11:35
- Location: PT
I have repeated the procedure and obtained a correct model. Moreover, we have performed some tests and have obtained the correct results using the following code:
Could you please explain the behaviour you expect to get?
What attributes are missing?
Could you please provide a failing code snippet?
Code: Select all
var q = context.Providers.OfType().ToList();
What attributes are missing?
Could you please provide a failing code snippet?