diff --git a/EntityFrameworkCore.Console/Program.cs b/EntityFrameworkCore.Console/Program.cs index 2cd74aa..abfa8aa 100644 --- a/EntityFrameworkCore.Console/Program.cs +++ b/EntityFrameworkCore.Console/Program.cs @@ -13,6 +13,17 @@ using var context = new DeadBallZoneLeagueDbContext(); // Rather than raise: "System.InvalidOperationException: Sequence contains no elements." // var firstCoach = await context.Coaches.FirstOrDefaultAsync(); +async Task DeleteCoach(int id) +{ + var coach = await context.Coaches.FindAsync(id); + if (coach != null) + { + context.Remove(coach); + // context.Entry(coach).State = EntityState.Deleted; + await context.SaveChangesAsync(); + } +} + async Task UpdateCoach() { var coach = await context.Coaches.FindAsync(1);