I am creating few models, inserting them with "InsertAsync" and at the end i am saving the changes with entity framework core.
What i would like to do is:
MasterDbContext.table1.AddAsync(object1);
var object2 = new table2()
{
Action = 1,
PrimaryRef = object1.primaryKey,
};
MasterDbContext.table2.AddAsync(object2);
But the that value is null, do you know how could i have a second insert with the value?
I mean, if they are executed one by one, entity framework should be able to map the value, if so, anybody knows how? thanks.
*** UPDATE
Basically to make it more simple:
I have a foreach loop where add (without saving) several object in table1 and table2.
In the same loop then i have to log the primary keys of both the tables in table3 (two different rows)
And then save everything at the end.
how can i take let EF know to take those primaryKeys?
But the that value is null,
- which value null?object1.primaryKey
is null?