相关疑难解决方法(0)

没有为此DbContext配置数据库提供程序

我最近将我的项目更新为最新版本的Entity Framework Core(+ VS2017).当我尝试更新数据库时,我收到以下错误消息.错误消息很明显,但似乎是错误的.我的ConfigureServices中有一个AddDbContext(参见下面的代码).

我错过了什么?

错误

> dotnet ef database update --verbose

Finding DbContext classes...
Using context 'ApplicationDbContext'.

System.InvalidOperationException: No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
Run Code Online (Sandbox Code Playgroud)

启动

public void ConfigureServices(IServiceCollection services) { …
Run Code Online (Sandbox Code Playgroud)

entity-framework entity-framework-core

6
推荐指数
1
解决办法
7457
查看次数