Skip to content

Bugfix/19601 can not add ef core migrations#19846

Merged
AndyButland merged 5 commits intoumbraco:mainfrom
idseefeld:bugfix/19601-Can-Not-Add-EFCore-Migrations
Aug 4, 2025
Merged

Bugfix/19601 can not add ef core migrations#19846
AndyButland merged 5 commits intoumbraco:mainfrom
idseefeld:bugfix/19601-Can-Not-Add-EFCore-Migrations

Conversation

@idseefeld
Copy link
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

This PR fixes #19601

Description

The issue was cause by missing database provider name which was removed in commit:

Commit d5ff803
Author: Nikolaj Brask-Nielsen nikolajgive@gmail.com
Authored Date: Mittwoch, 1. November 2023 09:59
Committer: Nikolaj Geisle 70372949+Zeegaan@users.noreply.github.com
Commit Date: Mittwoch, 1. November 2023 10:06
Parent: 107a70a

Fix custom dbcontexts extention methods (#14937)

  • test: Create failing test

  • feat: New extension methods for adding Umbraco DBContexts

  • test: Cleaned up integration tests

Test PR

  • Insure the 'src/Umbraco.Web.UI/appsettings.json' have a connection string set with the right provider e.g. SqlServer.
    Open terminal for solution in Visual studio

  • Execute: dotnet ef migrations add TestMigration -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.SqlServer -c UmbracoDbContext

  • Check migration exists

  • Remove migration by executing: dotnet ef migrations remove -s src/Umbraco.Web.UI -p src/Umbraco.Cms.Persistence.EFCore.SqlServer -c UmbracoDbContext

Copilot AI review requested due to automatic review settings August 3, 2025 11:14
@github-actions
Copy link

github-actions bot commented Aug 3, 2025

Hi there @idseefeld, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

Copy link
Contributor

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 fixes a bug where EF Core migrations could not be added due to missing database provider name information that was inadvertently removed in a previous commit. The fix updates the AddUmbracoDbContext extension method signatures to provide connection string and provider name parameters to configuration actions.

  • Updated extension method signatures to include connection string and provider name parameters
  • Modified the UmbracoDbContext constructor to properly resolve service providers and connection information
  • Updated test cases and documentation to reflect the signature changes

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
UmbracoEFCoreServiceCollectionExtensions.cs Updated extension method signatures to provide connection string and provider name to configuration actions
UmbracoDbContext.cs Enhanced constructor to resolve service providers and connection information, updated documentation
UmbracoEFCoreComposer.cs Updated method call to match new signature with additional parameters
CustomDbContextUmbracoProviderTests.cs Updated test cases to use new method signatures with additional parameters

@idseefeld
Copy link
Contributor Author

I have no clue😥
See also: #19845

Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

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

Thanks for working on and submitting this contribution @idseefeld. I've had a look and could verify both the linked issue and that this resolves the problem.

I've pushed a couple of updates to resolve the code review comments and fix the breaking changes that were otherwise causing the build errors you were seeing.

I think it's good now, but would appreciate you having a look over to check you are happy with the updates I made. And I'll likely get a second HQ opinion too as I'm not too familiar with what has gone previously on how we are using EFCore in Umbraco.

I saw you'd also raised #19845 for the same issue but for 17. I think we can close that if we merge this one in for 16. Do you agree please or is that adding something else that I've missed?

Copy link
Member

@Zeegaan Zeegaan left a comment

Choose a reason for hiding this comment

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

Also seems solid to me 👍

@idseefeld
Copy link
Contributor Author

@AndyButland Thank you for the fix.
I have checked the PR again and it fixes the issue.
Indeed #19845 can be closed now. I have done that.

@AndyButland AndyButland enabled auto-merge (squash) August 4, 2025 10:31
@AndyButland
Copy link
Contributor

Great, thanks again @idseefeld - will merge this in as soon as the build checks complete.

@AndyButland AndyButland merged commit 4bf2fbf into umbraco:main Aug 4, 2025
25 checks passed
@idseefeld idseefeld deleted the bugfix/19601-Can-Not-Add-EFCore-Migrations branch August 13, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can Not Add EFCore Migrations

4 participants