Entity framework (1): implement 1 foreign key to multiple tables
- by Michel
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