.NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore问题

编程入门 行业动态 更新时间:2024-10-26 00:24:00
本文介绍了.NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这里是否有人对 IBM.EntityFrameworkCore 包有经验?我在VS2017中创建了一个.NET Standard 2.0库项目,添加了提到的包,并尝试通过遵循此和此教程,没有运气。我已经编译了项目,但是在运行时我得到了 System.TypeLoadException 和以下消息:

Does anyone here has experience with IBM.EntityFrameworkCore package? I've created a .NET Standard 2.0 library project in VS2017, added mentioned package, and tried to make it work by following this and this tutorial from IBM website, with no luck. I get the project compiled, but at the runtime I'm getting a System.TypeLoadException with the following message:

Method 'ApplyServices' in type 'IBM.EntityFrameworkCore.Infrastructure.Internal.Db2OptionsExtension' from assembly 'IBM.EntityFrameworkCore, Version=1.1.1.101, Culture=neutral, PublicKeyToken=7c307b91aa13d208' does not have an implementation.

任何帮助将不胜感激!

谢谢!

更新:我尝试使用上下文后就会发生异常。这意味着之后成功创建了上下文,但是之前 DbContext.OnConfiguring 调用发生了。

Update: The exception happens as soon as I try to use the context. It means after the context is successfully created, but before DbContext.OnConfiguring call happens.

推荐答案

我已经解决了。事实证明,如果未在与上下文相同的程序集(项目)中定义实际实体类型(即 MyType ),则会发生此异常。在我的解决方案中,我在一个项目中定义了实体类型,而在另一个项目中定义了 DbContext ,当然,该类型引用了第一个。

I've solved it. It turned out that this exception happens if actual entity types (i.e. MyType) aren't defined in the same assembly (project) as the context. In my solution I had entity types defined in one project, and DbContextdefined in a different project, that references the first one, of course.

之所以要进行这样的设计,是因为有两个不同的软件包(取决于实际的操作系统): IBM.EntityFrameworkCore 和 IBM.EntityFrameworkCore-lnx 。因此,我创建了两个不同的项目,每个项目都引用其中一个软件包。仍然,我想一次定义所有实体类型...但是显然,它不能那样工作。

The reason for me to have such design was in the fact that there are two different packages (depending on the actual OS): IBM.EntityFrameworkCore and IBM.EntityFrameworkCore-lnx. So I've created two different projects, each referencing one of these packages. Still, I wanted to have all the entity types defined once... But obviously it cannot work like that.

更新:很遗憾,它事实证明,这不是唯一的问题。我遇到了另外一个问题,此处所述。拒绝DB2 .NET团队!与...合作总是令人沮丧的。

Update: Sadly, it turned out that this isn't the only issue. I've ran into another one, described here. Thumbs down for DB2 .NET team! It's always frustrating to work with...

更多推荐

.NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore问题

本文发布于:2023-11-17 04:29:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608831.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Standard   NET   IBM   EntityFrameworkCore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!