c# - Many to Many relationship EF with foreign keys -
I want to configure many relationships between 2 entities but I would also like to expose my foreign key. I found a solid solution online like the following:
modelbuilder.Entity & lt; E1 & gt; () .HasMany (t = & gt; TE1). With many (t => TA2S) .map (M => {M.TeTable ("E1E2"); M. MAPLft ("FKE1"); M. MapRightkey ("FKE2" );}); But the left and right key of the map does not take any quality from my model, so I do not have access to them and they will not be filled when I query. Therefore, I do not have access to my foreign key properties.
Hope I was able to describe my problem. Can someone recommend other options?
You can create an Associate Model which has the key to two entities: Public Sector Associate Entity {{Key] Public Gide Associate {Receives Antidiate; Set; } Public Guide Entity1Id {get; Set; } Public Guide Entity2Id {get; Set; } [Display (name = "unit 1", resource type = type (resource language))] public virtual unit 1 unit 1 {get; Set; } [Display (name = "unit 2", resource type = type (resource language))] Public Virtual Entity2 Entity2 {get; Set; }} Unit 1:
Public Class Entity1 {Key} Public Guid Entity1Id {get; Set; } / * Describe other properties * / [display (name = "associative attitudes", resource type = typef (language))] Public virtual Ichlanack & lt; Associate Antity & gt; Affiliations {Get; Set; }} Unit 2:
Public class Entity2 {[Key] Public Guide Entity2Id {get; Set; } / * Describe other properties * / [display (name = "associative attitudes", resource type = typef (language))] Public virtual Ichlanack & lt; Associate Antity & gt; Affiliations {Get; Set; }}
Comments
Post a Comment