Updating EntitySet/EntityContext to DbSet/DbContext
This commit is contained in:
parent
8bd2d01b11
commit
9d25c0b1f1
|
|
@ -137,7 +137,7 @@ namespace MusicStore.Controllers
|
|||
public IActionResult DeleteConfirmed(int id)
|
||||
{
|
||||
Album album = db.Albums.Single(a => a.AlbumId == id);
|
||||
// TODO [EF] Replace with EntitySet.Remove when querying attaches instances
|
||||
// TODO [EF] Replace with DbSet.Remove when querying attaches instances
|
||||
db.ChangeTracker.Entry(album).State = EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
return RedirectToAction("Index");
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ using Microsoft.AspNet.ConfigurationModel;
|
|||
|
||||
namespace MusicStore.Models
|
||||
{
|
||||
public class MusicStoreContext : EntityContext
|
||||
public class MusicStoreContext : DbContext
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
|
|
@ -18,12 +18,12 @@ namespace MusicStore.Models
|
|||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public EntitySet<Album> Albums { get; set; }
|
||||
public EntitySet<Artist> Artists { get; set; }
|
||||
public EntitySet<Order> Orders { get; set; }
|
||||
public EntitySet<Genre> Genres { get; set; }
|
||||
public EntitySet<CartItem> CartItems { get; set; }
|
||||
public EntitySet<OrderDetail> OrderDetails { get; set; }
|
||||
public DbSet<Album> Albums { get; set; }
|
||||
public DbSet<Artist> Artists { get; set; }
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
public DbSet<Genre> Genres { get; set; }
|
||||
public DbSet<CartItem> CartItems { get; set; }
|
||||
public DbSet<OrderDetail> OrderDetails { get; set; }
|
||||
|
||||
protected override void OnConfiguring(EntityConfigurationBuilder builder)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ namespace MusicStore.Models
|
|||
|
||||
foreach (var cartItem in cartItems)
|
||||
{
|
||||
// TODO [EF] Change to EntitySet.Remove once querying attaches instances
|
||||
// TODO [EF] Change to DbSet.Remove once querying attaches instances
|
||||
_db.ChangeTracker.Entry(cartItem).State = EntityState.Deleted;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue