How to set a collection-property with FKs?
问题 I have a Business and a Category model. Each Business has many Categories via an exposed collection ( Category is disregarding the Business entity). Now here is my controller-action: [HttpPost] [ValidateAntiForgeryToken] private ActionResult Save(Business business) { //Context is a lazy-loaded property that returns a reference to the DbContext //It's disposal is taken care of at the controller's Dispose override. foreach (var category in business.Categories) Context.Categories.Attach(category