This question is locked. New answers and comments are not allowed.
Hi all,
I'm noticing strange behavior in the working of join tables in OpenAccess.
Somehow adding records only seems to work in a one-way direction.
For example this works:
But this doesn't work:
The ProductMagager.Save and ProductCategoryManager.Save simply execute a context.add and context.SaveChanges.
When using the first code block, the records is saved in the join table. But when using the second block, no exception is thrown but no records are created either.
Any suggestions?
Regards,
Erik van Rijn
I'm noticing strange behavior in the working of join tables in OpenAccess.
Somehow adding records only seems to work in a one-way direction.
For example this works:
if
(!product.ProductCategories.Contains(productCategory))
{
productCategory.Products.Add(product);
ProductCategoryManager.Save(productCategory, context);
}
But this doesn't work:
if
(!product.ProductCategories.Contains(productCategory))
{
product.ProductCategories.Add(productCategory);
ProductManager.Save(product, context);
}
The ProductMagager.Save and ProductCategoryManager.Save simply execute a context.add and context.SaveChanges.
When using the first code block, the records is saved in the join table. But when using the second block, no exception is thrown but no records are created either.
Any suggestions?
Regards,
Erik van Rijn