当前位置:Gxlcms > 数据库问题 > asp.net Core EF core ( Entity Framework 7 ) 数据库更新维护

asp.net Core EF core ( Entity Framework 7 ) 数据库更新维护

时间:2021-07-01 10:21:17 帮助过:20人阅读

   print?技术分享技术分享
  1. using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())  
  2. {  
  3.     serviceScope.ServiceProvider.GetService<UnicornStoreContext>().Database.Migrate();  
  4.     serviceScope.ServiceProvider.GetService<ApplicationDbContext>().Database.Migrate();  
  5.     serviceScope.ServiceProvider.GetService<UnicornStoreContext>().EnsureSeedData();  
  6. }  


根据上面的代码换成自己的函数,即可

 

 

然后就可以根据生成的Mingrations文件夹内的文件,生成Mingrations API专属数据库,自动扩展,升级数据库

转载:http://blog.csdn.net/loongsking/article/details/63682952

asp.net Core EF core ( Entity Framework 7 ) 数据库更新维护

标签:data-   skin   env   text   nic   tor   tracking   自己   查看   

人气教程排行