entity framework - One to many relationship without navigation property -
entity framework - One to many relationship without navigation property -
public class myentity { public int myentityid { get; set; } public int foo { get; set; } public icollection<myentitydetail> myentitydetails { get; set; } } public class myentitydetail { [key, column(order=0)] public int pk { get; set; } // myentityid myentity [key, column(order = 1)] public int otherpk { get; set; } // manually set public string bar { get; set; } } public class myentitycontext : dbcontext { public dbset<myentity> myentities { get; set; } public dbset<myentitydetail> myentitydetails { get; set; } protected override void onmodelcreating(dbmodelbuilder modelbuilder) { modelbuilder.conventions.remove<pluralizingtablenameconvention>(); } }
i think above code explains im trying accomplish entity framework code first 4.2 note myentitydetail doesnt contain navigation property myentity. how associate myentityid myentity pk myentitydetail?? if have can add together myentity navigation property myentitydetail class dont want utilize memory property never access. , type of entites used 100+ times in project. thanks
unfortunately can't that. in case of one-to-one relationship possible fk pk, in one-to-many relationship not possible since kid table(myentitydetail table)'s pk unique value can't duplicated
entity-framework entity-framework-4 entity-framework-4.1 ef-code-first code-first
Comments
Post a Comment