Can one map multiple classes to one storage entity ie table? Potential issue with Colliding IDs

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
EdB
Posts: 91
Joined: Mon 15 Oct 2012 09:24

Can one map multiple classes to one storage entity ie table? Potential issue with Colliding IDs

Post by EdB » Fri 26 Apr 2013 11:07

Hi,

I am looking into the mapping of multiple Entities(Classes) onto one generic storage entity(Table). Theoretically this is all possible within ED, but I get an error about colliding IDs:

1 Problem in mapping fragments starting at line 426:EntitySets 'tClient1s' and 'Classes' are both mapped to table 'Classes'. Their primary keys may collide.
D:\Projects\MyProject\MyProject.Models\MyProject.edml

I can see the problem. The underlying table has its ID column set to INT32 and is an Identity column so autogenerates the PK.

Can I do this? How do I get around this error?

Thanks.

P.S I am currently mapping my Classes one to one with DB Views(Storage Objects) and this works fine. However I have just realised I should not need to set up DB Views as well since this is just another layer of mapping.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Can one map multiple classes to one storage entity ie table? Potential issue with Colliding IDs

Post by Shalex » Mon 29 Apr 2013 16:04

Please take a look at the sample of table splitting which shows the way how to map two classes in CSDL to the same table in SSDL: http://www.devart.com/entitydeveloper/e ... eloper.chm > ORM Support > Entity Framework > Concepts > Working with Classes > Table Splitting.

EdB
Posts: 91
Joined: Mon 15 Oct 2012 09:24

Re: Can one map multiple classes to one storage entity ie table? Potential issue with Colliding IDs

Post by EdB » Thu 02 May 2013 01:01

Hi,

This still seems to only allow one use of a Storage Object Property. For example if I do setup up table splitting on a table called Class and pull "Name" and "Value" to another entity, then "Name" and "Value" are not longer available for use by another entity. I guess I need "Table Sharing" not "Table Splitting".

What I need to do is create a number of different entities that map to the same Storage object, and within each Entity I can map each specific Property to the underlying Storage Object Column like how one would use a Database View. One can setup 10 different Views onto one Table and each can update the base table. So like this I need to setup ten different entities that map onto one base Storage Object(Table). Perhaps it is not possible without PKs colliding???

Without the ability to do this, then I need to create DB Views each of which becomes a Storage Object which each supporting a seperate Entity.

Any more thoughts please?

Thanks.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Can one map multiple classes to one storage entity ie table? Potential issue with Colliding IDs

Post by Shalex » Tue 14 May 2013 11:45

EdB wrote:I need to create DB Views each of which becomes a Storage Object which each supporting a seperate Entity.
This is correct.

Post Reply