c# - Mapping One to Many on non-primary key -
i doing code first entity model legacy database (simplified):
create table person ( personid int primary key nonclustered identity(1,1), name nvarchar(255), personsystemid nvarchar(50) not null unique ); create table address ( addressid int primary key nonclustered identity(1,1), propertydetails nvarchar(255), personsystemid nvarchar(50), foreign key (personsystemid) references person(personsystemid) )
the interesting detail address
table referencing personsystemid
instead of personid
real pk of person
table.
i want property called addresses
in person
class, , property person
in address
class. there way of mapping this? (fudges and/or cludges welcome).
note readonly database - don't need deal inserts/updates/deletes.
currently can't, available in future release.
we working on unique constraint support in ef7.
the workaround removing navigation properties , manually join entity.
var result = p in db.person join in db.address on p.personsystemid equals a.personsystemid select new { person = p, address = };
Comments
Post a Comment