dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.63k stars 25.3k forks source link

Concurrency Field - Not Reacting to Parameters Changing #33943

Open guardrex opened 4 days ago

guardrex commented 4 days ago

Description

Moved from https://github.com/dotnet/blazor-samples/issues/378 ...

https://github.com/dotnet/blazor-samples/blob/d000234099558a1db2258a77d242e04ef2a9cfe7/8.0/BlazorWebAppEFCore/Components/ConcurrencyField.razor#L36-L47

This should be using the OnParametersSet, such that when the DbModel changes the property is checked again. Also none of the properties of the Contact have ConcurrencyCheck attributes, so the newest EF core will not automatically fail. I suggest adding the ConcurrencyCheck attribute to at least one property or every property because the UI implies the whole object is checked for concurrency.

cc: @crazyfox55

Page URL

https://learn.microsoft.com/en-us/aspnet/core/blazor/blazor-ef-core?view=aspnetcore-8.0

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/blazor/blazor-ef-core.md

Document ID

2ebc5e4d-bab4-6d30-9018-9a712c482236

Article author

@guardrex

guardrex commented 4 days ago

@crazyfox55 ... Before I ping the product unit for assistance, what database provider are you using?

crazyfox55 commented 4 days ago

The database I'm using is sqlite, just like the sample uses.

guardrex commented 4 days ago

No 🎲🎲 with that provider ... it no-ops that way for sure. I added a paragraph on it to the article in the Sample app section a while back ...

The sample demonstrates use of EF Core to handle optimistic concurrency. However, native database-generated concurrency tokens aren't supported for SQLite databases, which is the database provider for the sample app. To demonstrate concurrency with the sample app, adopt a different database provider that supports database-generated concurrency tokens (for example, the SQL Server provider).

To confirm if your report is correct on that point about what the product unit sent over in the sample app, you would need to use a different provider that can take advantage of the automatic tokens ... OR ... do what you did (I think) and set up the concurrency manually and not try to rely on the automatic tokens.

Perhaps, what I should do here is take that paragraph and make a section out of it, which should help readers discover it.

... and then I'm not sure if ...

using the OnParametersSet, such that when the DbModel changes the property is checked again

... is a separate problem or not.

Pinging @mikekistler to take a look at this issue; and although he's no longer working Blazor issues, this is a sample that was originally provided by @JeremyLikness, and he might have a sec to remark on this.