.net - Can I map an EF entity to two tables with a polymorphic foreign key? -
i make new, mapped entity looks this:
public class patheditem { public long id { get; set; } // items table public string name { get; set; } // items table public string path { get; set; } // paths table }
the problem path
in different table other items , 1 of tables has polymorphic foreign key. here tables:
create table items ( [id] [bigint] identity(1,1) not null, [name] [nvarchar](255) not null) create table paths ( [id] [bigint] identity(1,1) not null, [path] [nvarchar](255) not null, [itemid] [bigint] not null, [itemtype] [int] not null)
microsoft has howtos on mapping entities 2 tables (here , here), seem rely on normal foreign key.
is there way map paths.itemid
items.id
, hardcode value paths.itemtype
in join?
one way create view, columns require , filter on itemtype.
then add view entity model.
Comments
Post a Comment