Skip to content

Conversation

ajcvickers
Copy link
Collaborator

No description provided.

@ajcvickers ajcvickers requested a review from damieng October 16, 2025 13:34
@ajcvickers ajcvickers requested a review from a team as a code owner October 16, 2025 13:34
@Copilot Copilot AI review requested due to automatic review settings October 16, 2025 13:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the MongoDB Entity Framework Core provider by moving database creation and index management logic from MongoClientWrapper to MongoDatabaseCreator. This is a pure refactoring that maintains existing behavior while improving the separation of concerns.

Key changes:

  • Moved database creation, deletion, and index management methods from IMongoClientWrapper/MongoClientWrapper to IMongoDatabaseCreator/MongoDatabaseCreator
  • Updated tests to use IMongoDatabaseCreator instead of IMongoClientWrapper for database operations
  • Simplified MongoDatabaseFacadeExtensions by adding a helper method to reduce code duplication

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
MongoDatabaseCreatorTests.cs New test file with tests moved from MongoClientWrapperTests, updated to use IMongoDatabaseCreator
MongoClientWrapperTests.cs Deleted - tests moved to MongoDatabaseCreatorTests
MongoDatabaseCreator.cs Added database creation, deletion, and index management methods previously in MongoClientWrapper
MongoClientWrapper.cs Removed database/index methods; exposed Client, Database, and DatabaseName as public properties
IMongoDatabaseCreator.cs Added interface methods for database existence checks, index creation, and vector index operations
IMongoClientWrapper.cs Removed database/index method signatures; added Client, Database, and DatabaseName property definitions
MongoDatabaseFacadeExtensions.cs Simplified extension methods using new GetDatabaseCreator helper method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@ajcvickers ajcvickers requested a review from Copilot October 16, 2025 13:45
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +178 to +182
// Internal because it is used by .NET 8 tests.
internal void SeedFromModel()
=> database.SaveChanges(AddModelData().GetEntriesToSave());

// Internal because it is used by .NET 9 tests.
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states this is 'used by .NET 8 tests', but given the async variant on line 185 states it's used by '.NET 9 tests', this distinction seems arbitrary. Consider clarifying why different .NET versions require different test methods or updating the comments to be more accurate.

Suggested change
// Internal because it is used by .NET 8 tests.
internal void SeedFromModel()
=> database.SaveChanges(AddModelData().GetEntriesToSave());
// Internal because it is used by .NET 9 tests.
// Internal for test compatibility: .NET 8 tests use the synchronous method, while .NET 9 tests use the asynchronous method.
internal void SeedFromModel()
=> database.SaveChanges(AddModelData().GetEntriesToSave());
// Internal for test compatibility: .NET 9 tests use the asynchronous method.

Copilot uses AI. Check for mistakes.

Comment on lines +66 to +69
public IMongoClient Client => _client ??= GetOrCreateMongoClient(_options, _serviceProvider);

/// <inheritdoc />
public async Task<IClientSessionHandle> StartSessionAsync(CancellationToken cancellationToken = default)
=> await Client.StartSessionAsync(null, cancellationToken).ConfigureAwait(false);
public IMongoDatabase Database => _database ??= Client.GetDatabase(_databaseName);
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] These properties changed from private to public. While this appears intentional for the refactoring, consider documenting in the property XML comments that these may trigger client initialization as a side effect.

Copilot uses AI. Check for mistakes.

{
// Do anything that causes an actual database connection with no side effects
clientWrapper.DatabaseExists();
DatabaseExists();
Copy link

Copilot AI Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call to DatabaseExists() is used only for its side effect of establishing a database connection. Consider adding a comment explaining this non-obvious behavior, or extracting to a method with a clearer name like EnsureConnected().

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant