There is a post that says how to do this but it does not explain how to work with it.
We have a class "Persoon" (dutch) in English 'Person' and we want to add a friend (vriend in Dutch) with an ICollection who's also a 'Person'
We have the following code in our domain class Persoon:
public virtual ICollection<Persoon> Vrienden { get; set; }
this is because one person can have many friends (vrienden in Dutch)
For implementing our Icollection and creating our friendship table we have used the following code:
modelBuilder.Entity<Persoon>()
.HasMany(m => m.Vrienden)
.WithMany()
.Map(w => w.ToTable("Vriendschap")
.MapLeftKey("PersoonID")
.MapRightKey("VriendID"));
Now is the question, we have created the friendship table but how can we now add Person's to the friendship table with PersoonID (personID) & vriendID (friendID). I know that you can use 'vrienden.Add(entity)' but I don't know how to use ith within a new controller like friendshipcontroller is this not necessary ?
How do we have to implement this in our controllers and views ? so that we can add, edit, delete en see a list from the collection ?
Thanks in advance!!