.NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore问题 [英] .NET Standard 2.0 / EntityFrameworkCore / DB2 / IBM.EntityFrameworkCore issue

查看:106
本文介绍了.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问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆