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. 转:C++何时调用构造函数,何时调用析构函数

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/wjf1997/article/detai ...

  2. vmware安装Linux

  3. Python 调用outlook发送邮件(转 )

    单账号: import win32com.client as win32 def send_mail(): outlook = win32.Dispatch('Outlook.Application' ...

  4. set serveroutput on 命令

    使用set serveroutput on 命令设置环境变量serveroutput为打开状态,从而使得pl/sql程序能够在SQL*plus中输出结果 使用函数dbms_output.put_lin ...

  5. C++ STL copy copy_backward

    #include <iostream>#include <algorithm>#include <vector>#include <functional> ...

  6. Linux-文件系统的简单操作

    文件系统的简单操作 磁盘与目录的容量:df.du df [option] [目录或文件名] 参数: -a:列出所有的文件系统,包括系统特有的/proc等系统 -k:以KB的容量显示各文件系统 -m:以 ...

  7. 10 Flutter仿京东商城项目 商品分类跳转到商品列表传值 商品列表页面布局

    pages下面新建: ProductList.dart import 'package:flutter/material.dart'; import '../services/ScreenAdaper ...

  8. Redis查询_Tips

    基础知识——介绍 Redis简介 REmote Dictionary Server(Redis) 是一个由Salvatore Sanfilippo写的key-value存储系统. Redis是一个完全 ...

  9. JAVA 基础编程练习题46 【程序 46 字符串连接】

    46 [程序 46 字符串连接] 题目:两个字符串连接程序 package cskaoyan; public class cskaoyan46 { public static void main(St ...

  10. process.env.NODE_ENV

    Node 随记 if (process.env.NODE_ENV === 'production') { module.exports = require('./prod.js') } else { ...