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.

http://data.uservoice.com/forums/72025-entity-framework-feature-suggestions/suggestions/1050579-unique-constraint-i-e-candidate-key-support

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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -