No database provider has been configured for this DbContext
2024-08-31 09:28:32
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;
最新文章
- 可爱的Python_课后习题_CDay−5 Python 初体验和原始需求
- 【网络流24题----03】Air Raid最小路径覆盖
- linux概念之IPC
- insert into (select...WITH CHECK OPTION) values(...)
- oracle简单两个操作
- 观察者模式在ng(Angular)中的应用
- python django 自定义 装饰器
- Windows Phone开发(35):使用Express Blend绘图
- jquery+html三级联动下拉框及详情页面加载时的select初始化问题
- 第二章	Idea搭建maven
- Git安装教程(windows)
- ADT打开layout目录的xml报错java.lang.NullPointerException
- 如何用jQuery获取选中行固定列的数据
- .NET手记-Autofac进阶(属性和方法注入 Property and Method Injection)
- 深入浅出的webpack构建工具---AutoDllPlugin插件(八)
- Centos 7上安装Elasticsearch
- StreamSets学习系列之StreamSets的Core Tarball方式安装(图文详解)
- oracle查询指定月份数据
- linux下pcf8563驱动时钟使用
- Kubernetes PV/PVC使用实践