This question is locked. New answers and comments are not allowed.
Hi - I'm new to OpenAccess, so I may just not be doing this right. I have a model that has a property that's 1:M. When I save the context, I see in the ORM profiler that it's loading the whole M:1 collection on the 1 before saving. Why would the framework need to load the whole collection just to associate 1 record? I'm using version 2012.3.1012.1. Here's my example in more concrete terms:
Invoice model has one Employee
Each Employee can have many Invoices they are associated with
I'm doing this, with an Employee model that's already been loaded from the DB:
Before saving the new Invoice record, I can see in the profiler that a LEFT JOIN from Employee to Invoice is executed, which is returning all of the Invoices for that employee. All I want it to do is set the foreign key value and save.
Thanks for your help,
Rob
Invoice model has one Employee
Each Employee can have many Invoices they are associated with
I'm doing this, with an Employee model that's already been loaded from the DB:
var invoice =
new
Invoice
{
CreatedDate = DateTime.UtcNow,
Employee = employee,
};
Context.Add(invoice);
Context.SaveChanges()
Before saving the new Invoice record, I can see in the profiler that a LEFT JOIN from Employee to Invoice is executed, which is returning all of the Invoices for that employee. All I want it to do is set the foreign key value and save.
Thanks for your help,
Rob