Category Table ;
public int CategoryId{ get; set; }
public string Name{ get; set; }
public List<ProductCategory> ProductCategories { get; set; }
I add new field to the table;
public int CategoryId{ get; set; }
public string Name{ get; set; }
public List<ProductCategory> ProductCategories { get; set; }
public string Url{ get; set; }
I get the following error when updating entity; Microsoft.EntityFrameworkCore.DbUpdateException: 'An error occurred while updating the entries. See the inner exception for details.'
eShopContext;
public DbSet<Product> Products{ get; set; }
public DbSet<Category> Categories{ get; set; }
public object Configuration { get; internal set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(
@"Server=gdagad;Database=eStoreAppDB;Trusted_Connection=True;");
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ProductCategory>()
.HasKey(c => new {c.CategoryId, c.ProductId});
}
}
SeedDatabase.cs;
Use the EF Core Migrations feature to update the database.
add a new field to an ASP.NET Core MVC app