Given 3 database tables: Businesses, Markets, BusinessesMarkets
I want to add a new business and I want the business to be in a particular market. How do I add to the join table in EntityFramework speak?
For example, the user wants to create a new business called ABC Co and add it to the Southern region market.
This is making some assumptions about your domain model:
var southernRegion = db.Markets().Find(the_id);
var abcCo = new Business();
southernRegion.Businesses.Add(abcCo);
db.SaveChanges();
EF will handle the join table for you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With