c# - Modelling a nullable foreign key Entity Framework -
take following pseudocode database
table foo { fooid int not null, name varchar not null } table bar { barid int not null, name varchar not null } table waa { waaid int not null, name varchar not null } table link { linkid int not null, fooid int null, barid int null, waaid int null, description varchar not null }
the purpose of link table allow me link entities in single table, without having multiple foo_bar_link
, foo_waa_link
etc. tables.
i moddeling db in entityframework v5. such, want able specify 1 many relationship between foo
, link
, can links associated given foo.
problem
entityframework designer lets one-many relationships exist foreign key not null. want foo have navigation property associations
gets of association
entities fooid = foo.fooid
. note, using designer.
ef not designed support unusual models yours. way know insert "empty" meaning rows example id equals -1
. in business logics or in dto implement "clever" getter , setter.
Comments
Post a Comment