I am using ASP.NET MVC .
I am trying to create 2 new records in 2 tables – employee and address table.
I have the following so far:
db.employee.AddObject(empmodel.employee);
db.address.AddObject(empmodel.address);
db.SaveChanges();
When an employee record is created, it creates an EmpID record which is autogenerated.
I need to get that EmpID and create a new record in the address table with that EmpID as
as there is a primary foreign key relationship between the 2 tables.
I am not sure how to get the EmpID from employee table and then create a new record for the address table. I thought I could get it after AddObject but it did not create an employee record.
You can try saving changes after adding employee.