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的更多相关文章

  1. SQLite EF Core Database Provider

    原文链接 This database provider allows Entity Framework Core to be used with SQLite. The provider is mai ...

  2. InvalidOperationException: No file provider has been configured to process the supplied file.

    现在有一个api, 提供图片的下载,如下代码,,调试出现 InvalidOperationException: No file provider has been configured to proc ...

  3. 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 ...

  4. 一步步学习EF Core(1.DBFirst)

    前言 很久没写博客了,因为真的很忙,终于空下来,打算学习一下EF Core顺便写个系列, 今天我们就来看看第一篇DBFirst. 本文环境:VS2017  Win7  .NET Core1.1     ...

  5. entity framework core在独立类库下执行迁移操作

    之前学习EFCore的时候,都是在VS创建的默认模板里面进行的,按照官方文档,直接就可以搞定. 今天新项目准备上.Net Core,打算先按照国际惯例,进行分层,数据访问层是用EFCore来做,于是就 ...

  6. 关于VS2017 添加 EF的MVC控制器报错的解决方法

    1. 错误描述 :no database provider has been configured fot this DbContext. 此类错误是上下文的注册造成的.解决方式在DBContext中 ...

  7. Configuring and troubleshooting a Schema Provider

    原文:https://codesmith.atlassian.net/wiki/display/Generator/Configuring+and+troubleshooting+a+Schema+P ...

  8. 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 ...

  9. 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 - ...

随机推荐

  1. bootstrap 上下页滚动

    <!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8" ...

  2. JMeter首金网自营项目-转义及数据库数据乱码的解决

    param的string参数: 需要对”进行转义,加/ { "prdCreditInfo": { "revision": 0, "maxCredit& ...

  3. Clock Generator PLL with Integrated VCO_ADF4360-9

    Clock Generator PLL with Integrated VCO_ADF4360-9     2和3之间需要有大于15ms的时间间隔

  4. C之指针的加法

    #include<stdio.h> #include<stdlib.h> main() { //char arr [] = {'H','e','l','l','o'}; int ...

  5. smarty {for}{forelse}

    {for} {for}{forelse}用于创建一个简单的循环. 下面的几种方式都是支持的: {for $var=$start to $end}步长1的简单循环. {for $var=$start t ...

  6. Qt编写自定义控件21-圆弧仪表盘

    一.前言 圆弧仪表盘在整个自定义控件大全中也稍微遇到了技术难点,比如背景透明,如果采用以前画圆形画扇形的方式绘制,肯定很难形成背景透明,需要用到切割,最后换了一种绘制方法,采用绘制圆弧的方式,即使用d ...

  7. PAT 甲级 1021 Deepest Root (25 分)(bfs求树高,又可能存在part数part>2的情况)

    1021 Deepest Root (25 分)   A graph which is connected and acyclic can be considered a tree. The heig ...

  8. 一个小故事,玩转Python-while循环

    无论是传统编程场景还是当下火爆的人工智能应用场景,循环的应用都是必不可少的,上一篇文章中阐述了如何使用for循环来进行编程,这篇文章将会由一个小朋友经常听的故事来讲Python编程中的while循环. ...

  9. idea-配置文件提示红色

    Idea建立spring配置文件首行红色 提示URI is not registered 复制出现红色字体的路径...File -  Settings  - schemas and DtDs 点击加号 ...

  10. postman 发送json 格式数据

    hearder 设置 body 设置 { ", "primary_content": "{\"SN\":129,\"MPBH\&q ...