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的更多相关文章
- SQLite EF Core Database Provider
原文链接 This database provider allows Entity Framework Core to be used with SQLite. The provider is mai ...
- InvalidOperationException: No file provider has been configured to process the supplied file.
现在有一个api, 提供图片的下载,如下代码,,调试出现 InvalidOperationException: No file provider has been configured to proc ...
- EF Core In-Memory Database Provider
原文链接 This can be useful for testing, although the SQLite provider in in-memory mode may be a more ap ...
- 一步步学习EF Core(1.DBFirst)
前言 很久没写博客了,因为真的很忙,终于空下来,打算学习一下EF Core顺便写个系列, 今天我们就来看看第一篇DBFirst. 本文环境:VS2017 Win7 .NET Core1.1 ...
- entity framework core在独立类库下执行迁移操作
之前学习EFCore的时候,都是在VS创建的默认模板里面进行的,按照官方文档,直接就可以搞定. 今天新项目准备上.Net Core,打算先按照国际惯例,进行分层,数据访问层是用EFCore来做,于是就 ...
- 关于VS2017 添加 EF的MVC控制器报错的解决方法
1. 错误描述 :no database provider has been configured fot this DbContext. 此类错误是上下文的注册造成的.解决方式在DBContext中 ...
- Configuring and troubleshooting a Schema Provider
原文:https://codesmith.atlassian.net/wiki/display/Generator/Configuring+and+troubleshooting+a+Schema+P ...
- Cannot obtain the required interface ("IID_IDBCreateCommand") from OLE DB provider "OraOLEDB.Oracle" for linked server xxxx
今天遇到了一个关于LINKED SERVER查询报错的案例,链接服务器链接ORACLE数据库,测试没有错误,但是执行脚本的时候,报如下错误: Msg 7399, Level 16, State 1 ...
- uninstall 11.2.0.3.0 grid & database in linux 5.7
OS: Oracle Linux Server release 5.7 DB: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - ...
随机推荐
- js循环数组(总结)
js循环数组(总结) 一.总结 一句话总结: for循环:for(j = 0,len=arr.length; j < len; j++) {} foreach循环:arr.forEach((it ...
- linux:解决SSH连接Linux超时自动断开
用SSH登录到Linux的时候,由于默认的连接超时时间很短,经常断开! 1.修改文件 # vi /etc/ssh/sshd_config 2.重启sshd服务 # /etc/init.d/sshd r ...
- 004-log-common-logging,Apache整合日志框架JCL门面框架、JCL+log4j
一.概述 Jakarta Commons Logging (JCL)提供的是一个日志(Log)接口(interface),同时兼顾轻量级和不依赖于具体的日志实现工具.它提供给中间件/日志工具开发者一个 ...
- PLSQL Developer配置OCI连接远程数据库
转: PLSQL Developer配置OCI连接远程数据库 当前环境: 本机系统:Win7 32位 PLSQL版本:9.06 数据库版本:10.2 32位 下面开始具体操作. 1.在Oracle官网 ...
- C++ STL 逆转旋转 reverse reverse_copy rotate
#include <iostream>#include <algorithm>#include <vector>#include <iterator> ...
- 用ConfigMap管理配置(10)
一.ConfigMap介绍管理配置: ConfigMap介绍 Secret 可以为 Pod 提供密码.Token.私钥等敏感数据:对于一些非敏感数据,比如应用的配置信息,则可以用 ConfigMa ...
- 【ARTS】01_29_左耳听风-201900527~201900602
ARTS: Algrothm: leetcode算法题目 Review: 阅读并且点评一篇英文技术文章 Tip/Techni: 学习一个技术技巧 Share: 分享一篇有观点和思考的技术文章 Algo ...
- 【世界之大,我用Python】Ubuntu 自动删除自带软件
起因 Ubuntu是用来做开发程序的系统,如果存在大量的"垃圾"软件就不好了吧,不仅影响系统性能而且还会经常报错,所以每次安装完系统都会清理一次系统. 操作 我清理系统一般都是直接 ...
- Android之makefile
在Android的源代码中,随处可见Makefile,那么Makefile到底是用来干嘛的呢?其实Makefile和Maven.ANT.Gradle一样,属于构建工具,当项目比较庞大的时候,就可以使用 ...
- redis安装-备份-恢复
1.安装参考:https://www.jb51.net/article/146744.htm 2.安装ruby2.3.3 .gpg2 --keyserver hkp://keys.gnupg.net ...