Entity framework (1): implement 1 foreign key to multiple tables

Posted by Michel on Stack Overflow See other posts from Stack Overflow or by Michel
Published on 2010-06-07T14:38:14Z Indexed on 2010/06/07 14:42 UTC
Read the original article Hit count: 357

Hi,

i've modeled this:

i have an import table, and an import steps table

import 1 .. N importsteps

Now i have a table importparams, which hold key/value pairs to register all kind of info about the import or the importsteps. So i have modeled a FK in SqlServer which points to the PK of the import table and to the PK of the importsteps table (the ID's for both the import as the importsteps table are guids, so i can query the importparams with either the id from import or from importsteps and get the right importparams).

Makes sense a bit?

But how can i model this in the EF?

I can see it's a bit hard for the EF to model this, because one realtion can point to multiple classes, but is there a way?

The workaround normally is just to get all importparams where FK is the ID, but as you know the FK is not available in the EF version 1.

I hope you can help me out,

michel

© Stack Overflow or respective owner

Related posts about c#

Related posts about entity-framework