在新的ASP.NET MVC 6身份的AspNetUsers表中的ConcurrencyStamp列的目的是什么? [英] What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity?

查看:2716
本文介绍了在新的ASP.NET MVC 6身份的AspNetUsers表中的ConcurrencyStamp列的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的ASP.NET MVC 6标识中 AspNetUsers 表中的 ConcurrencyStamp 列的目的是什么?

What is the purpose of the ConcurrencyStamp column in the AspNetUsers table in the new ASP.NET MVC 6 identity?

这是 AspNetUsers 表的数据库模式:

它也在 AspNetRoles 表格:

因为我记得在ASP.NET MVC 5身份。

As I remember it wasn't there in the ASP.NET MVC 5 identity.

到目前为止我注意到,它似乎有GUID值,因为它是用下面的代码定义的:

What I've noticed so far is that it seems to have GUID values as it is defined with the following code:

/// <summary>
/// A random value that must change whenever a user is persisted to the store
/// </summary>
public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString();

但是这篇文档不足以让我理解在哪种情况下使用它。

But this documentation is not sufficient for me to understand in which situations it is used.

推荐答案

从源代码本身

    /// <summary>
    /// A random value that should change whenever a role is persisted to the store
    /// </summary>
    public virtual string ConcurrencyStamp { get; set; } = Guid.NewGuid().ToString();

基本上,看它的名字。用于标识数据的当前版本的戳记。

Basically, see it as it is named. A stamp that is used to identify the current version of the data. If you change it, so does the stamp.

因此,如果两个并发更新同时出现,则它们必须具有相同的戳记,或者其中一个应该被丢弃。

So if two concurrent updates comes in at the same time, they must have the same stamp or one of them should be discarded.

因此,名称 ConcurrencyStamp

这篇关于在新的ASP.NET MVC 6身份的AspNetUsers表中的ConcurrencyStamp列的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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