为什么呢?
已经解决了,我真是个傻子。
把startup里services.AddDbContext<AppDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));(正确的)
写成了services.AddDbContext<AppDbContext>(options => options.UseSqlServer("DefaultConnection"));(错的)
这是我上一步操作生成的文件