-
Notifications
You must be signed in to change notification settings - Fork 20
Adding EF core, database project, and some usage. #3674
Adding EF core, database project, and some usage. #3674
Conversation
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Outdated
Show resolved
Hide resolved
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a few concerns here. The "Changes Requested" refers only to item 1 below, which is about the tests. The rest could be considered general feedback for future iterations.
Requested Changes
- This really needs tests around the database functionality and the data objects within. No one should be able to cause a problem here that breaks the db or data model without a test failing and blocking the checkin. If we accidentally ship with such a db problem, that could create a cascade of data issues across many customers and we will forever have to deal with that possible state and recover from it. This absolutely needs tests that run as part of the CI validation to prevent this.
Things to consider not blocking
-
There is no schema control over the data, so it would be easy for someone to add columns or data and create a migration problem without realizing we have a migration problem. At the very least the schema needs to be versioned and I strongly recommend explicitly setting the schema and not letting Entity's Magic do it to where someone can easily and unknowingly change the schema and create a migration problem without knowing it.
-
There's very little logging about what Entity Framework is doing. I'm not a fan of Entity, as it does a little too much "magic" and not enough visibility. To resolve this while still using Entity, I think there needs to be a lot more try-catch around various things with appropriate logging added in so we can help diagnose a problem. We may get random exception and have a malformed db and no idea why or how it got that way.
-
In general I'm expecting that nearly anything with working with the DB could throw for filesystem reasons, database locked reasons, unique constraint violation, or any number of things could go wrong and we could get corrupt data outside of using it in a sqlite transaction and rolling back the change. Without the transactions corruption seems very likely, and without try-catches around many of these things this could be a random crash factory.
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Show resolved
Hide resolved
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Show resolved
Hide resolved
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Show resolved
Hide resolved
database/DevHome.Database/Migrations/DevHomeDatabaseContextModelSnapshot.cs
Outdated
Show resolved
Hide resolved
| .ToList() | ||
| .ForEach(x => dbContext.Repositories.Remove(x)); | ||
|
|
||
| dbContext.SaveChanges(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not familiar with what magic EntityFramework might be doing, but SQLite has transaction support where you can ensure data integrity should something go wrong with any of this.
I don't see much in the way of try-catch blocks for things going wrong and I'm particularly nervous about not having fine control over the schema, transactions, etc to ensure data integrity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but SQLite has transaction support
By default Entity Framework uses Transactions any SaveChange
try-catch blocks for things going wrong is put inside a transaction.
They will be added later. The purpose of this PR is to get the database structure and some usage examples into the feature branch. More try/catches will be added after this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fine control over the schema, transactions, etc to ensure data integrity.
The schema is defined by the C# classes. We will have finer control over the schema. EF generates SQL scripts from migrations. When the schema is updated human eyes will review the generated script.
The migration strategy is as follows
During Dev-Inner loop. Use Migrations.
During a version change with a new schema: Generate a SQL script based on the migrations and get sign-off that the script is correct. Database migrations will use the script.
As I said in another comment, EF uses transactions by default.
What other concerns around data integrity do you have?
I will add tests for the current usage. I will add more in future PRs when I add implementations.
In this PR. Correct. This PR is for getting the database and some usage into the feature branch. I will add logic to check the schema version in a future PR. I promise. Further, Entity Frame does not have a method for detecting schema changes for packages.
I will add more logging in future PRs (Before the feature gets into main).
I did run into exceptions as well. I will add more try/catches in future PRs. This includes telemetry. Another reason to add the database code in a PR with minimum try/catch and logging is to enable multiple branches to work on the database. Specifically when one PR is in review. I can work on another Repository Management feature while the other PR is in review. |
...oryManagement/DevHome.RepositoryManagement/Services/RepositoryManagementDataAccessService.cs
Show resolved
Hide resolved
...oryManagement/DevHome.RepositoryManagement/Services/RepositoryManagementDataAccessService.cs
Show resolved
Hide resolved
database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs
Outdated
Show resolved
Hide resolved
database/DevHome.Database/Migrations/20240823230859_InitialMigration.cs
Outdated
Show resolved
Hide resolved
...oryManagement/DevHome.RepositoryManagement/Services/RepositoryManagementDataAccessService.cs
Show resolved
Hide resolved
database/DevHome.Database/Migrations/20240823230859_InitialMigration.cs
Outdated
Show resolved
Hide resolved
...oryManagement/DevHome.RepositoryManagement/Services/RepositoryManagementDataAccessService.cs
Show resolved
Hide resolved
database/DevHome.Database/Migrations/20240823230859_InitialMigration.Designer.cs
Show resolved
Hide resolved
...oryManagement/DevHome.RepositoryManagement/Services/RepositoryManagementDataAccessService.cs
Show resolved
Hide resolved
jsidewhite
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
![]()
#3709) * Refining Repository Management's UI. (#3557) * Adding the Repository tool * WIP * View is set up. Test ata as well. * Aligning columns. Adding column spacing. * Reverting this change * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Adressing comments * Revert "Reverting this change" This reverts commit 711dd78. * Moving to experimental * Disabling by default * Removing from experimental. Addressing comments. * Reverting to main * Update tools/RepositoryManagement/DevHome.RepositoryManagement/DevHome.RepositoryManagement.csproj Co-authored-by: Kristen Schau <[email protected]> * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Extensions/ServiceExtensions.cs Co-authored-by: Kristen Schau <[email protected]> * Removing duplicate xaml code * Adding to the mermaid diagram * Got lost in the shuffle * Removing a refrence --------- Co-authored-by: Kristen Schau <[email protected]> * Adding EF core, database project, and some usage. (#3674) * WIP * EF works. Can save data. * Can read and write. :) * Repos are added when cloned. * Putting save/load into a different class * Adding default values * Cleaning up names and using statements * More comments * Removing refrence to the public nuget * Restoring the nuget config * Adding a test. Better defining dates * Adding some tests * More comments. * Better path comparison. * Removing unused equals code * Adding more comments. Making new migrations * Moving this to experimental * Some comments and fixes * Changing to Windows.SDK and re-adding projects --------- Co-authored-by: Kristen Schau <[email protected]>
* Refining Repository Management's UI. (#3557) * Adding the Repository tool * WIP * View is set up. Test ata as well. * Aligning columns. Adding column spacing. * Reverting this change * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Adressing comments * Revert "Reverting this change" This reverts commit 711dd78. * Moving to experimental * Disabling by default * Removing from experimental. Addressing comments. * Reverting to main * Update tools/RepositoryManagement/DevHome.RepositoryManagement/DevHome.RepositoryManagement.csproj Co-authored-by: Kristen Schau <[email protected]> * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Extensions/ServiceExtensions.cs Co-authored-by: Kristen Schau <[email protected]> * Removing duplicate xaml code * Adding to the mermaid diagram * Got lost in the shuffle * Removing a refrence --------- Co-authored-by: Kristen Schau <[email protected]> * Adding EF core, database project, and some usage. (#3674) * WIP * EF works. Can save data. * Can read and write. :) * Repos are added when cloned. * Putting save/load into a different class * Adding default values * Cleaning up names and using statements * More comments * Removing refrence to the public nuget * Restoring the nuget config * Adding a test. Better defining dates * Adding some tests * More comments. * Better path comparison. * Removing unused equals code * Adding more comments. Making new migrations * Moving this to experimental * WIP * Some telemetry and logging * THings build again. * Returning this back * I believe I am understanding this. * Can update * Almost done with open in FE * Try/Catching everything. Open in FE should be done. * Open in CMD works. :) * Re-adding changes lost due to merge * Getting saving straightened out. * WIP * Move Repository done. * Removing 1:1. Finishing RemoveFromList * Adding _items * Adding configuration file information to the repository table * Opening the configuration file location in FE * Deleting a repository. * Add to winget configuration file. * Cleaning up the code * Icon for a configuration file. UI updates when hiding a repo * All the buttons do something. * Removing 'local' * Making sure the test works * New test works * Another TODO * Fixing more things before PR. * Removing another un-used using. * MOre un used usings. * Another Todo * Anotehr TODO * Changing a comment * Update database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs Co-authored-by: Branden Bonaby <[email protected]> * Comments * Don't just merge code and expect things to work. * What is in a name? * Adressing comments * Updated the database migration. --------- Co-authored-by: Kristen Schau <[email protected]> Co-authored-by: Branden Bonaby <[email protected]>
* Refining Repository Management's UI. (#3557) * Adding the Repository tool * WIP * View is set up. Test ata as well. * Aligning columns. Adding column spacing. * Reverting this change * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Adressing comments * Revert "Reverting this change" This reverts commit 711dd78. * Moving to experimental * Disabling by default * Removing from experimental. Addressing comments. * Reverting to main * Update tools/RepositoryManagement/DevHome.RepositoryManagement/DevHome.RepositoryManagement.csproj Co-authored-by: Kristen Schau <[email protected]> * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Extensions/ServiceExtensions.cs Co-authored-by: Kristen Schau <[email protected]> * Removing duplicate xaml code * Adding to the mermaid diagram * Got lost in the shuffle * Removing a refrence --------- Co-authored-by: Kristen Schau <[email protected]> * Adding EF core, database project, and some usage. (#3674) * WIP * EF works. Can save data. * Can read and write. :) * Repos are added when cloned. * Putting save/load into a different class * Adding default values * Cleaning up names and using statements * More comments * Removing refrence to the public nuget * Restoring the nuget config * Adding a test. Better defining dates * Adding some tests * More comments. * Better path comparison. * Removing unused equals code * Adding more comments. Making new migrations * Moving this to experimental * WIP * Some telemetry and logging * THings build again. * Returning this back * I believe I am understanding this. * Can update * Almost done with open in FE * Try/Catching everything. Open in FE should be done. * Open in CMD works. :) * Re-adding changes lost due to merge * Getting saving straightened out. * WIP * Move Repository done. * Removing 1:1. Finishing RemoveFromList * Adding _items * Adding configuration file information to the repository table * Opening the configuration file location in FE * Deleting a repository. * Add to winget configuration file. * Cleaning up the code * Icon for a configuration file. UI updates when hiding a repo * All the buttons do something. * Removing 'local' * Making sure the test works * New test works * Another TODO * Fixing more things before PR. * Removing another un-used using. * MOre un used usings. * Another Todo * Anotehr TODO * Localized strings * WIP * Adding enhanced information if it can be found. * Commit, Filtering, and Sorting. * Fixing up the merge * Removing Move/Delete because of a bug in FileExplorerGitIntegration. * Adding a TODO * A small commit * Removing some unused usings * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Update tools/RepositoryManagement/DevHome.RepositoryManagement/Strings/en-us/Resources.resw Co-authored-by: Kristen Schau <[email protected]> * Adressing comments * Adressing comments * Addressing code quality comments * Update database/DevHome.Database/DatabaseModels/RepositoryManagement/Repository.cs Co-authored-by: Ryan Shepherd <[email protected]> * Fixing some issues. * Added a TODO * Adding drop down to select a source control provider * Hide source control selection * FIxing indentation --------- Co-authored-by: Kristen Schau <[email protected]> Co-authored-by: Ryan Shepherd <[email protected]>
Summary of the pull request
Adds the DevHome.Database project that houses the dbcontext for interacting with the database.
Adds more logic to the RepositoryManagement page.
Adds some database usage.
References and relevant issues
Detailed description of the pull request / Additional comments
More documentation added in the future.
Validation steps performed
Manually ran.
PR checklist
Movies!

Cloning repos and showing them in the Repository Management Screen.
Removing a repository in FE and showing the change in the Repository Management page.
