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 - ...
随机推荐
- MyBatis——特殊传参问题小结
近期在写系统报表API的时候遇到MyBatis中的一些特殊写法: 1. 传入两个参数(一般情况下我们更多的是传入一个对象或者map) public List<MarketVehicleModel ...
- kotlin函数的参数和返回值
fun main(arg: Array<String>) { val asList = asList(, , , , , ) println(asList) } fun <T> ...
- 13Flutter页面布局 Wrap组件
/* Flutter页面布局Wrap组件: Wrap可以实现流布局,单行的Wrap跟Row表现几乎一致,单列的Wrap则跟Row表现几乎一致. 但Row与Column都是单行单列的.Wrap则突破了这 ...
- kettle的用法
一: 从一个数据库导入表的数据到另一个 数据库的表中(表数据同步) 1:在 主对象树-- DB连接 中新建 连接: 在选项中 设置字符集: 2: 在 核心对象中 先增加一个 表输入: 再增加一个 插 ...
- 自然语言处理(NLP)之个人小结
一 概述 1.1 自然语言处理四大任务 序列标注 分词 词性标注 命名实体识别 分类任务 文本分类 情感分析 判断句子关系 问答系统 对话系统 阅读理解 生成任务 机器翻译 自动文摘 图像描述生成 1 ...
- ubuntu kylin 18.04 使用 wine 安装 EasyConnect 的windows版本
首先下载wine: sudo apt-get install wine-stable 然后使用wine安装安装包EXE文件(安装包你自己去下): wine EasyConnectInstaller.e ...
- LODOP纸张高度不定的纯文本累计高度
小票由于纸张没有确定的高度,根据内容多少,小票打印机出多少纸,在设置纸张的时候,需要把纸张设置成不定高的纸张.简短问答:小票打印 ,参考样例18 http://www.c-lodop.com/demo ...
- [leetcode_easy]558. Quad Tree Intersection
problem 558. Quad Tree Intersection re 1. Leetcode_easy_558. Quad Tree Intersection; 2. Grandyang; e ...
- Android之view的工作原理2
学习内容 View的底层工作原理,比如View的测量流程.布局流程以及绘制流程:以及常见的View回调方法:熟悉掌握前面的知识后,自定义View的时候也会更加的得心应手. 4.1 初识ViewRoot ...
- [转帖]curl网站开发指南
curl网站开发指南 http://www.ruanyifeng.com/blog/2011/09/curl.html linux 里面有非常多很好的工具 比如这个 curl 之前 以为 wget 就 ...