Skip to content
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

Concurrency Field - Not Reacting to Parameters Changing #33943

Open
guardrex opened this issue Oct 28, 2024 · 10 comments · May be fixed by #34453
Open

Concurrency Field - Not Reacting to Parameters Changing #33943

guardrex opened this issue Oct 28, 2024 · 10 comments · May be fixed by #34453

Comments

@guardrex
Copy link
Collaborator

Description

Moved from dotnet/blazor-samples#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 guardrex added ⌚ Not Triaged Source - Docs.ms Docs Customer feedback via GitHub Issue labels Oct 28, 2024
@guardrex
Copy link
Collaborator Author

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

@crazyfox55
Copy link

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

@guardrex
Copy link
Collaborator Author

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.

@guardrex
Copy link
Collaborator Author

Pinging @mikekistler again to take a look at ...

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

Note that on the other point about the sample not working OOB for concurrency that it uses SQLite OOB, which doesn't support database-generated concurrency tokens. Presumably, changing to SQL Server, for example, will result in the concurrency feature lighting up in the app. The article already covers it, but I'm going to make a section out of the remarks to make it easier for readers to discover this point.

@mikekistler
Copy link
Contributor

@guardrex I'd like to help here but the problem seems to be something in either Blazor or EF Core and I'm not very knowledgable in either of these. Perhaps @javiercn can help?

@guardrex
Copy link
Collaborator Author

If he knows, sure.

I think I probably should just use SQL Server for the app to light-up the concurrency feature ... and then it should be easy to confirm if the ConcurrencyField component should be using OnParameterSet instead of OnInitializedAsync.

Not sure when I'll reach this. I'm still working on the WASM+Identity 2FA/TOTP stuff, and I still have a handful of .NET 9 items that I'd like to address before we bug out for the 🦃 day holiday.

@guardrex
Copy link
Collaborator Author

guardrex commented Dec 5, 2024

UPDATE (12/5): I'm working on getting back to this issue, but we have internal projects going on and a backlog of higher-priority items + holiday vacations + exhausted folks 😩. I'll get back here ASAP 🏃‍♂.

@guardrex
Copy link
Collaborator Author

UPDATE (12/20): This didn't make it for '24 due to other high priority work items, but that backlog has largely been cleared out. I'll be back from the 🎄 holidays in January to work on this.

@guardrex
Copy link
Collaborator Author

guardrex commented Jan 8, 2025

Ok ... I'm BACK! 🏃‍♂

I'm going to consider adding content to use the sample with SQL Server to light up the concurrency features that were built into the sample app. I don't want to move the sample to SQL Server, and I don't want to remove the bits that Jeremy put into the sample app to manage concurrency. We'll see how it turns out! 🤞🍀

@guardrex
Copy link
Collaborator Author

guardrex commented Jan 8, 2025

OK ... well ... good news on this thus far. Here's the concurrency working with a SQL Server dB provider. I opened this in two browsers, edited the record in one and then tried to change it in the other. Looks good. 👍

Now, I'll see if I can craft some simple scaffolding guidance for the article.

Image

@guardrex guardrex moved this from Triage to In progress in Blazor.Docs Jan 8, 2025
@guardrex guardrex linked a pull request Jan 8, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging a pull request may close this issue.

3 participants