using Demo.Data; using Demo.Domain; using Microsoft.EntityFrameworkCore; using System; using System.Linq; namespace Demo.App { class Program { static void Main(string[] args) { using var context = new DemoContext(); //Delete //只能删除被追踪的数据 var tiaojian = "AC Milan"; var milan = context.Clubs.Single(x=>x.Name== tiaojian); context.Clubs.Remove(milan); context.Remove(milan); //context.Clubs.RemoveRange(milan,milan); //context.RemoveRange(milan,milan); var count = context.SaveChanges(); Console.ReadKey(); } } }