-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Explicitly configuring value generation: add [Timestamp]
#3165
Comments
There's this sentence right below the SQL Server Guid generation one which you cited (though it's more of an example on how value generation works, and indeed doesn't mention the
At least in my mind, we tend to distinguish between "simple" value generation and automatically-generated concurrency tokens such as rowversion. The distinction isn't 100% rigorous or anything, but a meaningless concurrency token which changes on each update pretty much cannot be used for anything other than concurrency checks; Guid generation on add is useful in other ways, i.e. to assign primary keys. This is why we have two separate pages for value generation and for concurrency tokens. We can definitely link the concurrency token page from the value generation page, though I think it still makes sense to keep most concurrency token information in its separate page.
No, client-side value generation (with a ValueGenerator such as SequentialGuidValueGenerator) work only on add (dotnet/efcore#6999 tracks this). Client-side value generation is generally not documented enough, I was planning to work on this in #3057 - I can do that now along with the changes you're working on.
I'm not sure exactly what you're asking... EF Core has a convention which identifies the Re SQL Server vs. Sqlite... When your database supports a data type that gets automatically generated on each update (such as rowversion on SQL Server), that's usually the simplest and recommended way to do optimistic concurrency. Sqlite doesn't have this, so it's the user's responsibility to generate manage Guids on each update. When we do dotnet/efcore#6999, things would become easier for Sqlite (and other databases with a similar situation). |
With the following in a model:
Why is the following code in the b.Property<byte[]>("ConcurrencyToken")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion"); So the question is about
Then why is |
I see what you mean now - yeah, that sentence is incorrect, it should be |
This was already fixed - we now say "specifying ValueGeneratedOnAdd has no effect", instead of ValueGeneratedOnAddOrUpdate. |
This was already fixed - we now say "specifying ValueGeneratedOnAdd has no effect", instead of ValueGeneratedOnAddOrUpdate. |
1 similar comment
This was already fixed - we now say "specifying ValueGeneratedOnAdd has no effect", instead of ValueGeneratedOnAddOrUpdate. |
Given that
[Timestamp]
is the recommended approach for concurrency tokens, that should be added to the Explicitly configuring value generation section.In the article:
Does that only work on add? What about
ValueGeneratedOnAddOrUpdate
? If it works onValueGeneratedOnAddOrUpdate
, isGUID
a good alternative to using[Timestamp]
?With the following in a model:
Why is the following code in the
BuildModel
method generated for the preceding code?The [SQLite and SQL Server concurrency versions]
(https://github.com/dotnet/AspNetCore.Docs/blob/fbea9dcb0b62f6a238498361ecd1e69358224718/aspnetcore/data/ef-rp/intro/samples/cu50/Pages/Departments/Edit.cshtml.cs) in dotnet/AspNetCore.Docs#21576 in have only the following differences:
It's tempting to use GUID for both, but
[Timestamp]
is the recommended approach for SQL Server.Please assign to me if appropriate and issue is accepted. cc @JeremyLikness @AndriySvyryd
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: