当前位置:Gxlcms > 数据库问题 > sqlite + .net core ef 3

sqlite + .net core ef 3

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

}, "Logging": { "LogLevel": { "Default": "Information", "Microsoft": "Warning", "Microsoft.Hosting.Lifetime": "Information" } }, "AllowedHosts": "*" }

 

3. 在Startup.cs的ConfigureServices方法中添加服务

  1. <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> ConfigureServices(IServiceCollection services)
  2. {
  3. <span style="color: #ff0000;">services.AddDbContext</span></span><span style="color: #ff0000;"><ApplicationDbContext>(options => options.UseSqlite($Configuration.GetConnectionString("sqliteConnection")</span><span style="color: #000000;"><span style="color: #ff0000;">));</span>
  4. services.AddDefaultIdentity</span><IdentityUser>().AddEntityFrameworkStores<ApplicationDbContext><span style="color: #000000;">();
  5. services.AddRazorPages();
  6. services.AddServerSideBlazor();
  7. services.AddScoped</span><AuthenticationStateProvider, RevalidatingAuthenticationStateProvider<IdentityUser>><span style="color: #000000;">();
  8. services.AddSingleton</span><WeatherForecastService><span style="color: #000000;">();
  9. }</span>

4.复制一个空的sqlite数据库文件到项目里,设置较新时复制,生成操作生成一下项目

5.迁移代码,用包管理器的命令行初始化数据库

  1. Add-<span style="color: #000000;">Migration Init<br></span>

 

7.作者暂时重启一下电脑

sqlite + .net core ef 3

标签:ext   public   认证   管理   ide   包管理器   getc   tar   cti   

人气教程排行