- AddOrUpdate, .. identifierExpression. , , . identifierExpression, , . , .
t.Products , , , , , Products, , , Products . , ( , ).
context.Transactions.AddOrUpdate(
new Transaction {
Products = new List<Product>(
pr.Where(p => p.Name == "Book" || p.Name == "Table"))
},
new Transaction
{
Products = new List<Product>(
pr.Where(p => p.Name == "Chair" || p.Name == "Book" || p.Name == "Table"))
}
);
Seed , Transaction Product . , EF. , .
( Context):
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Transaction>().HasMany(x => x.Products).WithMany();
}
, , Products Transaction virtual.