Skip to content

Warn on Migrate() when there are pending model changes #33732

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
Tracked by #19587
AndriySvyryd opened this issue May 16, 2024 · 1 comment · Fixed by #34199
Closed
Tracked by #19587

Warn on Migrate() when there are pending model changes #33732

AndriySvyryd opened this issue May 16, 2024 · 1 comment · Fixed by #34199

Comments

@AndriySvyryd
Copy link
Member

It should throw by default.

Related to #22105

@AndriySvyryd AndriySvyryd added this to the Backlog milestone May 16, 2024
@AndriySvyryd AndriySvyryd self-assigned this May 16, 2024
@AndriySvyryd AndriySvyryd modified the milestones: Backlog, 9.0.0 Jun 20, 2024
@AndriySvyryd AndriySvyryd removed their assignment Jul 10, 2024
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 11, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 12, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 15, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
@ajcvickers ajcvickers modified the milestones: 9.0.0, 9.0.0-rc1 Aug 21, 2024
@roji roji modified the milestones: 9.0.0-rc1, 9.0.0 Oct 12, 2024
@topstop3416
Copy link

topstop3416 commented Apr 18, 2025

asp.net core configuration provider that reads configuration key-value pairs from a database using Entity Framework Core

dotnet ef migrations add throw PendingModelChangesWarning

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-9.0#custom-configuration-provider

public class EFConfigurationProvider : ConfigurationProvider
{
    public EFConfigurationProvider(Action<DbContextOptionsBuilder> optionsAction)
    {
        OptionsAction = optionsAction;
    }

    Action<DbContextOptionsBuilder> OptionsAction { get; }

    public override void Load()
    {
        var builder = new DbContextOptionsBuilder<EFConfigurationContext>();

        OptionsAction(builder);

        using (var dbContext = new EFConfigurationContext(builder.Options))
        {            
            dbContext.Database.Migrate();    // throw PendingModelChangesWarning when dotnet ef migrations add

            Data = dbContext.Values.ToDictionary(c => c.Id, c => c.Value);
        }
    }
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants