CLR 使用实体框架检测到无效程序

发布于 2024-10-27 07:19:10 字数 359 浏览 4 评论 0原文

我正在从 wordpress 数据库中检索数据,该数据库将主键定义为十进制,并且我在项目上使用 x64 配置...

我搜索的位发现这是问题所在,但我找不到解决方案。

我需要做什么/下载什么才能使用十进制作为主键?

这个Microsoft Connect 上的问题

I am retrieving data from a wordpress database which defines the primary key as decimal and I am using a x64 configuration on the project...

The bit I searched I found out that it is the problem, but I couldn't find a solution.

What do I have to do/download to be able to use decimal as a primary key?

This issue on Microsoft Connect

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

月下凄凉 2024-11-03 07:19:10

我遇到了同样的问题,今天通过将 DBContext 对象中的这两个选项设置为 false 解决了它:

this.ContextOptions.LazyLoadingEnabled = false;

this.ContextOptions.ProxyCreationEnabled = false;

这似乎是代理创建的序列化问题。

我首先尝试将我的类型映射到 EDMX 文件中的 Int32,但这给我带来了非常低的性能。

I had the same problem and I solved it today by putting those two options to false in the DBContext object:

this.ContextOptions.LazyLoadingEnabled = false;

this.ContextOptions.ProxyCreationEnabled = false;

It seems to be a serialization problem with the proxy creation.

I tried first to map my types to Int32 in the EDMX file but this gave me very low performances.

旧情别恋 2024-11-03 07:19:10

如果您只从表中读取数据,您可以尝试创建一个将字段转换为 int 的视图,然后将实体映射到该视图。

除此之外,我认为你运气不太好。这是实体框架中的一个错误;要么更改字段类型,放弃 EF,要么等待 MS 修复错误。

If you're only reading data from the table you can try creating a view that casts the field to an int and then map your entity to the view.

Beyond that, I think you're pretty much out of luck. This is a bug in Entity Framework; either change the field type, switch away from EF, or wait for MS to fix the bug.

夢归不見 2024-11-03 07:19:10

您是否尝试过 Entity Framework 4.1 Release Candidate?该错误在大约一个月前就被标记为已修复。

Have you tried the Entity Framework 4.1 Release Candidate? The bug was marked as fixed as month or so back.

溺ぐ爱和你が 2024-11-03 07:19:10

我遇到了同样的问题,遗憾的是:微软仍然没有解决这个问题。我尝试了 EF 4.1 和 EF 5.0,但它们不包含针对此问题的任何修复。

到目前为止,唯一的解决方法是将所有十进制主键更改为 Int64。当然,这是数据库模式的更改,这不是您想要的。另一种选择是使用 32 位环境,该错误仅存在于 64 位中。

PJ(于 2011 年 11 月 11 日上午 11:46 )对 https://connect.microsoft.com/VisualStudio/feedback/details/620031/invalidprogramexception-using-entityframework-poco-template-table-w-decimal -primary-key 听起来根本没有希望,也许它甚至没有在 .NET 4.5 中修复

I ran into the same problem, and sad to say: it is still not fixed by Microsoft. I tried EF 4.1 and EF 5.0, but they do not contain any fix for this problem.

The only workaround so far was to change all decimal primary keys to Int64. That, of course, is a change in DB schema, which is not what you wanted. The other option is to use 32 bit environment, that bug is present in 64 bit only.

The comment by PJ (on 11/11/2011 at 11:46 AM ) on https://connect.microsoft.com/VisualStudio/feedback/details/620031/invalidprogramexception-using-entityframework-poco-template-table-w-decimal-primary-key does not sound promising at all, maybe it's not even fixed in .NET 4.5

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文