Linq2Entities: Update relationship?
- by Poku
Hey,
How do i create a new row in a table which have a relationship with another table?
I have an Employees table and a EmployeeProjects table. One Employee can have 1-* EmployeeProjects.
Now i want to create a new EmployeeProject which relates to an Employee. How do i do this?
Here is want i have tried so far:
var ep = new EmployeeProjects();
ep.JobNo = jobNo;
employee.EmployeeProjects.Add(ep);
var originalEmployee = GetEmployee(employee.Id);
_entities.ApplyPropertyChanges(originalEmployee.EntityKey.EntitySetName, employee);
_entities.SaveChanges();