C#C
C#4y ago
kopuo.

DbContext.SaveChangesAsync has no effect on the collection of changed objects

Hi. I get products collection from dbContext, change some values and want to save it in the database, but after SaveChangesAsync () is done in the database there are no changes. When previewing objects from dbContext at the end, I also cannot see the edited fields:
var products = await _dbContext.Products.AsEnumerableAsync()

foreach(var p in products)
{
  if(p.Price == 0)
    p.Price = 10
}

await _dbContext.AddRangeAsync(products);

await _dbContext.SaveChangesAsync();


Product is an entity btw.
Was this page helpful?