No database provider has been configured for this DbContext
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了No database provider has been configured for this DbContext相关的知识,希望对你有一定的参考价值。
var context = ((IInfrastructure<IServiceProvider>)set).GetService<DbContext>();
在EF Core 1.0 中会出现如下错误
Unhandled Exception: 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.
解决方案:
var context = ((IInfrastructure<IServiceProvider>)set).GetService<ICurrentDbContext>().Context;
以上是关于No database provider has been configured for this DbContext的主要内容,如果未能解决你的问题,请参考以下文章
android 插入资料到数据库时的错误android.database.sqlite.SQLiteException: table imagetable has no c
django-AttributeError: 'str' object has no attribute 'decode'
django-AttributeError: 'str' object has no attribute 'decode'
TCP Provider The semaphore timeout period has expired
helm 错误the server has asked for the client to provide credentials