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. impdp不是内部或外部命令(Linux)

    1.在windows环境变量下,配置path系统变量. 右击“我的电脑”—>“高级”—>“环境变量”—>“系统变量”—>path:然后添加";oracle导入导出命令 ...

  2. win10+mysql8.0安装

    一.下载 mysql8.0 windows zip包下载地址: https://dev.mysql.com/downloads/mysql/   1540951981(1).png 二.安装 1.解压 ...

  3. 图解 HTTP 笔记(五)——Web 服务器

    该章的主要内容是讲解与 HTTP 协作的 Web 服务器 一.用单台虚拟主机实现多个域名 基于虚拟主机的功能,可以只使用一台物理机实现多个域名的网站部署. 在互联网上,域名通过 DNS 域名解析系统可 ...

  4. 【UI】数据表格设计

    https://www.smashingmagazine.com/2019/02/complex-web-tables/ https://www.smashingmagazine.com/2019/0 ...

  5. Flutter 状态管理 flutter_Provide

    项目的商品类别页面将大量的出现类和类中间的状态变化,这就需要状态管理.现在Flutter的状态管理方案很多,redux.bloc.state.Provide. Scoped Model : 最早的状态 ...

  6. pip install locustio报错

    安装locust时, 执行pip install locustio时报错 ERROR: Cannot uninstall 'requests'. It is a distutils installed ...

  7. 使用canal通过mysql复制协议从binlog实现热数据nosql缓存(2)

    开启mysql binlog功能 以5.7版本为例,找到/etc/mysql/mysql.conf.d/mysqld.cnf [mysqld] pid-file = /var/run/mysqld/m ...

  8. Linux基础(特基本的那种)知识

    (自己的随手笔记,记得有点乱请轻喷) which:查看某个命令的完整路径df -h:查看系统磁盘情况history:查看历史输入的命令 网卡配置路径:vim /etc/sysconfig/networ ...

  9. 【Gstreamer开发】用 GStreamer 简化 Linux 多媒体开发

    原文:http://www.ibm.com/developerworks/cn/linux/l-gstreamer/ 一.基本概念 GStreamer 作为 GNOME 桌面环境推荐的流媒体应用框架, ...

  10. Django各个文件中常见的模块导入

    app01 app01 urls.py from django.conf.urls import url from django.contrib import admin from admins im ...