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 - ...
随机推荐
- 性能分析 | Java进程CPU占用高导致的网页请求超时的故障排查
一.发现问题的系统检查: 一个管理平台门户网页进统计页面提示请求超时,随进服务器操作系统检查load average超过4负载很大,PID为7163的进程占用到了800%多. 二.定位故障 根据这种故 ...
- SQL-W3School-基础:SQL INSERT INTO 语句
ylbtech-SQL-W3School-基础:SQL INSERT INTO 语句 1.返回顶部 1. INSERT INTO 语句 INSERT INTO 语句用于向表格中插入新的行. 语法 IN ...
- mac下不允许安装除了app store之外的软件设置:
1.dock栏的系统偏好设置. 2.找到安全性与隐私 3.点击面板中的通用,在点击左小角的锁按钮, 4.选择任何来源,确定就可以了.[如果只有两个选项,而没有任何来源的话,打开终端,执行:sudo s ...
- 阶段5 3.微服务项目【学成在线】_day05 消息中间件RabbitMQ_14.RabbitMQ研究-与springboot整合-搭建环境
我们选择基于Spring-Rabbit去操作RabbitMQ https://github.com/spring-projects/spring-amqp 使用spring-boot-starter- ...
- Spring事务管理4-----声明式事务管理(2)
声明式事务管理 基于AspectJ的 XML 方式配置 通过对事务管理器TransactionManager配置通知(增强),然后再配置切点和切面,详细见applicationContext.xml ...
- Spark中的CombineKey()详解
CombineKey()是最常用的基于键进行聚合的函数,大多数基于键聚合的函数都是用它实现的.和aggregate()一样,CombineKey()可以让用户返回与输入数据的类型不同的返回值.要理解C ...
- 【网站部署】flask
记录下常用的命令: nohup gunicorn --workers=2 --timeout=400 app:app &ps -ax scp -p ./***.h5 user@**.**.** ...
- 编译bitcoin比特币客户端
我遇到了两个不太容易解决的问题. 问题一: checking for Berkeley DB C++ headers... default configure: error: Found Berkel ...
- 使用super函数----增量重写普通方法和构造方法
使用super函数----增量重写普通方法和构造方法 在子类中如果重写了超类的方法,通常需要在子类方法中调用超类的同名方法,也就是说,重写超类的方法,实际上应该是一种增量的重写方式,子类方法会在超类的 ...
- Hadoop 部署之 ZooKeeper (二)
目录 一.Zookeeper功能简介 二.ZooKeeper基本概念 1.集群角色 三.ZooKeeper 的安装 1.下载安装(在datanode节点安装) 2.配置ZooKeeper环境变量 3. ...