Jordan nash fix crud app
Fixes Issue_Number #24541
Please advise that this PR is created to correct the application files for .NET 6 and is a companion to PR #27314 which I made solely for Crud.md.
I did it this way so as to divide the PRs into smaller ones.
I have read all the contribution guidelines for this repository and are using the Learn Authoring Pack for Visual Studio Code and have successfully used DocFX to test for any changes locally. I am done now with both pull requests and will leave it to you to make a decision. Thanks.
@LayersOfAbstraction I think the best approach to fixing this problem is to make the navigation property nullable. That fixes the problem. Then add paragraph that asp-validation-summary="ModelOnly" misses some errors that asp-validation-summary="All" catches.
@LayersOfAbstraction I hate to propose this after you've done so much work. @tdykstra @mkArtakMSFT @rafikiassumani-msft:
- Do you agree with my solution?
- Should I open a bug in the templates that they should use
asp-validation-summary="All"rather thanasp-validation-summary="ModelOnly"?
@tdykstra sorry about throwing 2 different PRs your way, mate! The reason I made 2 is that I thought it would be easier if I had one for doc changes and for app upgrades so both PRs are smaller.
Looks like it makes it more confusing. @Rick-Anderson recommends I apply changes from #27314 to here which I've done.
I'm going to close #27314. I'll let you decide what to do with this one. I should be done now. Thanks.
Thank you for this submission, Jordan. A couple of observations:
- The problem only occurs when you are targeting .NET 6.
- The tutorial hasn't been updated for .NET 6, and many of the changes required for .NET 6 aren't obvious; they require a level of ASP.NET Core knowledge that we don't expect in this tutorial's audience just to get as far as the CRUD tutorial successfully.
- When I go through the tutorial while targeting .NET 6, I encounter a problem with the DBInitializer class caused by the Enrollments nav property not being nullable. In order to successfully seed the database, I make the Enrollments property nullable, which means I don't see the Create problem when I get to the CRUD tutorial.
With that in mind, I think that rather than focus on the CRUD tutorial it might be more helpful to add some text in the Prerequisites section warning of problems ahead if you try to target .NET 6 or 7. Here I think we can:
- Briefly explain that NRT (nullable reference types) is enabled by default in .NET 6 or 7, mention a couple of the problems that causes, and link to https://learn.microsoft.com/ef/core/miscellaneous/nullable-reference-types for more information. This would be a good place to bring up ModelOnly vs. All and explain how to disable NRT for people who don't want to deal with it.
- Perhaps mention a few of the other changes required by .NET 6 or 7.
We do plan to update this tutorial per #26505, but there are competing priorities and it will be a while before we get to it.
Ok, sure I can warn them about this in the prerequisite section. Except it would mean changing the Intro.md file where the Prerequisites section is to include the ModelOnly vs All explanation and NTR with link. I can briefly duplicate some of the text to there that I wrote:
And then include the snippet for that which in this branch I called snippet_NullableEnrollments and mention the NTR.
> * Perhaps mention a few of the other changes required by .NET 6 or 7.
So I could advise the user of the Minimal Hosting model in .NET 6. I plan to update Intro.md later to include the minimal hosting model anyway just not in this PR, please.
That said I think I may have to make a whole new PR for the intro.md file where the prerequisite section is. Or do you want me to put that in this one branch too, please?
That said I think I may have to make a whole new PR for the intro.md file where the prerequisite section is. Or do you want me to put that in this one branch too, please?
I'm guessing a new PR would be easier. We could really use your help when we upgrade the entire series in reviews, etc.
That said I think I may have to make a whole new PR for the intro.md file where the prerequisite section is. Or do you want me to put that in this one branch too, please?
I'm guessing a new PR would be easier. We could really use your help when we upgrade the entire series in reviews, etc.
I'll do my best, and open a new branch tonight on this, thanks.
Superseded by https://github.com/dotnet/AspNetCore.Docs/pull/27593