MVC ошибка при удалении обьекта с базы даных

public async Task<ActionResult> DeleteProduct(Product product)
    {
        _dbContext.Products.Remove(product);
        await _dbContext.SaveChangesAsync();
        return RedirectToAction("Index");
    }

InvalidOperationException: The property 'Product.Id' has a temporary value while attempting to change the entity's state to 'Deleted'. Either set a permanent value explicitly, or ensure that the database is configured to generate values for this property.

Вот код ошибки, как можно исправить.


Ответы (0 шт):