首页 > 解决方案 > 突然出现大量 EF 实现错误

问题描述

我们在项目中使用的是 Entity Framework 6.4.4,最近遇到了一个严重的问题。在运行 10-20 小时(可能大约一百万个请求)后,我们突然收到大量 EF 实现错误。看起来所有的 EF 映射都因为某种原因搞砸了,即使是 Find 等基本方法也使用了错误的属性。

我们收到的错误的几个示例:

The '...' property on '...' could not be set to a 'System.Byte' value. You must set this property to a non-null value of type 'System.Guid'. at 
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.HandleEntityAppendOnly[TEntity](Func`2 constructEntityDelegate, EntityKey entityKey, EntitySet entitySet) at lambda_method(Closure , Shaper )

Shaper....SingleOrDefault[TSource]_InternalSet`1.FindInStore_InternalSet`1.Find
The '...' property on '...' could not be set to a 'System.Byte' value. You must set this property to a non-null value of type 'System.DateTime'

所有这些代码在某个特定时刻之前都有效,因此它看起来不像我们现有映射的问题。到目前为止,我们无法找到任何类似的问题。也许升级到 EF Core 可以解决这些问题,但这需要大量的时间投资,所以现在我们正在寻找一个临时解决方案。

有没有人知道可能导致这种情况的信息?我们希望至少弄清楚这是否主要是由负载过重引起的,以便我们可以优化和扩展我们的代码或我们的某种错误。

标签: entity-framework

解决方案


推荐阅读