Entity Framework map using Foreign Key and type field -


this simplified version of problem i'm facing. basically, have existing database code-first entity framework on top of, , there several tables see objectid , objecttype field. depending on objecttype, table can joined 1 of several other disparate tables not share hierarchy.

for example, given following database tables:

create table barcode ( id int not null primary key, objecttype int not null, objectid int not null, barcodevalue varchar(20) not null, )  create table person ( id int not null primary key, name varchar(20), )  create table package ( id int not null primary key, name varchar(20), ) 

i might see rows in barcode table objecttype of 1, correspond person records, or rows objecttype of 2, correspond package records.

in entity framework, how set mapping person entity can have barcode , package entity can have barcode? don't see map() method allows specify fields other foreign key field. said, there's no hierarchy among these objects, it's more share common attribute. sort of decorating class interface vs. having inherit something.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -