8.5K Star 14.1K Fork 4.2K

GVPdotNET China/Furion

 / 详情

Db.GetNewDbContext()无效

已完成
创建于  
2021-02-23 10:57

Furion 1.4.3

1.4.3


Web 项目类型

  • WebApi
  • Mvc
  • Razor Pages
  • Blazor Server

描述你的问题

在Task中使用Db.GetNewDbContext(),实际没有new新的DbContext,怀疑是生命周期出问题了。
我手撸了一个DbContext发现可以,应该是Fur出问题了


异常堆栈信息

Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances.


代码或代码仓库

输入图片说明

数据库信息

  • [] Sqlite
  • SqlServer
  • Mysql
  • Oracle
  • PGSql
  • Firebird
  • Cosmos

期待结果

期待的结果是?


评论 (2)

三月 创建了任务 4年前
三月 关联仓库设置为百小僧/Furion 4年前
三月 修改了描述 4年前
展开全部操作日志

确实是 Furion 框架问题,已经修复,晚点更新call你,测试代码。

public void 测试数据库上下文()
        {
            for (int i = 0; i < 3; i++)
            {
                using (var db = Db.GetNewDbContext())
                {
                    var p = db.Set<Person>().FirstOrDefault(u => u.Id == 1);
                    Console.WriteLine(p.Name);
                }
                using (var db1 = Db.GetNewDbContext())
                {
                    var p = db1.Set<Person>().FirstOrDefault(u => u.Id == 1);
                    Console.WriteLine(p.Name);
                }
            }
        }
百小僧 任务状态待办的 修改为进行中 4年前
百小僧 负责人设置为百小僧 4年前
百小僧 添加协作者dotNET China 4年前
百小僧 添加了
 
漏洞
标签
4年前
百小僧 添加了
 
优先
标签
4年前
百小僧 里程碑设置为Furion 2021 4年前
百小僧 计划截止日期设置为2021-02-24 4年前
百小僧 计划开始日期设置为2021-02-23 4年前
百小僧 计划截止日期2021-02-24 修改为2021-02-23 4年前
百小僧 置顶等级设置为 4年前
百小僧 优先级设置为严重 4年前
百小僧 通过 dotnetchina/Furion Commit fd2eec1任务状态进行中 修改为已完成 4年前
百小僧 置顶等级 修改为不置顶 4年前

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(3)
974299 monksoul 1578937227 1719691 sanyue6666 1615268019 8055741 chinadotnet 1606890988
C#
1
https://gitee.com/dotnetchina/Furion.git
git@gitee.com:dotnetchina/Furion.git
dotnetchina
Furion
Furion

搜索帮助