Root object(class) in Domain Object Model
I have a question, the question is:
In the ADO.NET vNext Entity Data Framework how do I solve the problem of having a root object in my domain model?
Let's say in my domain object model I have to have a root class from where every other class will be inherited. Obviously the root class does not need to be persisted, it simply adds some behavior to all the objects that I am going to use in my application.
While playing with the August CTP, I noticed that I could not make this work. Maybe I'm missing something. Maybe there are ways to get around this problem, can anyone please shed some lights on it?
[777 byte] By [
Puspak] at [2008-2-22]
What you can do is define an Entity Type in your Entity Model (in the CSDL file) and declare all other Entity Types to inherit from that one.
Just having an Entity Type doesn't make it persistent. If you don't have any Entity Sets that indicate that have instances of that type, then it won't be a persisted type, but the conceptual schema will include it.
Once you did that, when code-gen happens the base type that you created will be emited, and then you can add other elements such as transcient state and behaviors using a partial class.
Pablo Castro
ADO.NET Technical Lead
Microsoft Corporation
Hi Pablo,
I tried the way you said, it compiled but got this message when I tried to run the program:
Entity 'BaseCustomer' in schema 'NorthwindLib.Model,CSpace,0.0,null' should have at least one property to uniquely identify them. Please ensure that at least one property is passed as keys.
Yes, I made a 'BaseCustomer' entity and I made the 'Customers' entity derive from it. I am using the old Northwind database.
Is it true that I need to declare at least one property that uniquely identifies an Entity Type? When I did try to mention a property as a key there, my project wouldn't compile saying that the derived types can not declare keys when there is a key already declared in the base type. Now my whole point of having a root class is to give some behaviour to all the objects that I'm going to use in the project. I'm not sure I should use some fictitious id and try to get around this problem, but in that case, my derived types would not have a proper key.
Could you please suggest me some further reading where I can get help on this issue?
Thank you very much for your previous reply, it got me started again.
Puspak