❔ Entity Framework, How To Join Second Table To Third Table In The First Table?
Hi i want to join table city to area like picture below, but i got an error like this
anyone know how to do it properly? im only know to join the first and second table and still learning ty.
7 Replies
Just so you know,
builder.Property(x => x.Prop)
without actually configuring that property is useless
Also, how do your models look?
The error, of course, is that a foreign key has to be a property
Not a property of an object
So ab.City.AreaId
is not validwelp i think i could cheat like that xD
it was a simple model like this
Ah, a many-to-many relationship with additional data on the pivot table, basically?
Uh, kinda
Because City and Area also have a direct relationship
yeah prob like that, Area it should be Provience but i forgot to change the name
my man, i accidentally found it!
just change my linq query from this
to this
also add prop
public virtual Area { get; set; }
in City Model
and remove Join Area in AreaBranch Builder
here some result from my JSON
idk why if i exclude Area = areaBranch.City.Area
from my linq, my City didnt want to show up Area, but hei if its work its work.
anyway ty that was fastUnknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Use the /close command to mark a forum thread as answered
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.