I have 2 Models, each having many properties - Object1 and Object2
I have foreign key relationship with them in SQL db - Object1 can have many Object2's
Upon creating Object2 in my Object2Controller's Create() Method, how would I associate Object2 with Object 1's Guid?
Here is code:
Controller:
[HttpPost]
public ActionResult Create(Object2 object2)
{
if (ModelState.IsValid)
{
object2.Object2Id = Guid.NewGuid();
db.Object2.Add(object2);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(object2);
}