没有并发检查的实体框架IsRowVersion() [英] Entity Framework IsRowVersion() without concurrency check

查看:255
本文介绍了没有并发检查的实体框架IsRowVersion()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个表,该表具有名为 Version 的列,该列映射为SQL rowversion 。这样做是因为我们有一个外部系统,该系统映射到我们的数据,该数据依赖于每次更新表时此列的更改。最初,我们希望通过SQL处理此问题,但是现在,我们发现我们有乐观并发异常。尽管存在这些例外情况可以防止数据被覆盖,但对于我们来说,我们并不在乎这一点。我们只是希望 timestamp 继续增加,而无需Entity Framework对其并发问题进行检查。

We have a table that has a column called Version that is mapped as a SQL rowversion. This is done because we have an external system that maps to our data that relies on this column changing every time the table is updated. Originally we wanted this to be handled by SQL, but now we are finding we have Optimistic Concurrency exceptions. While these exceptions are there to safeguard data getting overwritten, for our case we do not care about this. We simply want the timestamp to continue incrementing, without Entity Framework checking it for concurrency issues.

有什么办法吗?去做这个?

Is there any way to do this?

映射:

Property(t => t.Version).IsRowVersion();


推荐答案

默认情况下,EF表示行版本类型是乐观的并发令牌(包括在乐观并发检查中)。

By default EF implies row version type to be a optimistic concurrency token (included in the optimistic concurrency checks).

您可以使用 IsConcurrencyToken fluent API覆盖该行为。 :

You can override that behavior by using the IsConcurrencyToken fluent API:

Property(t => t.Version).IsRowVersion().IsConcurrencyToken(false);

这篇关于没有并发检查的实体框架IsRowVersion()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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