1.引用Microsoft.AspNetCore.Mvc.NewtonsoftJson
2.Startup类中修改ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<StudyContext>(opt =>
opt.UseInMemoryDatabase("SqlServerConnection"));
services.AddControllers().AddNewtonsoftJson(options => {
//设置时间格式
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";
});
}
生成就ojbk了