Skip to content

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

Description

@AndriySvyryd

It should throw by default.

Related to #22105

Activity

  1. added this to the Backlog milestone on May 16, 2024
  2. self-assigned this
    on May 16, 2024
  3. modified the milestones: Backlog, 9.0.0 on Jun 20, 2024
  4. removed their assignment
    on Jul 10, 2024
  5. added 6 commits that reference this issue on Jul 10, 2024
    3e1018b
    0cc77a8
    d018d29
    84ebd38
    df97340
    69bcb92
  6. added a commit that references this issue on Jul 27, 2024
    f0fbcbe
  7. modified the milestones: 9.0.0, on Aug 21, 2024
  8. modified the milestones: , 9.0.0 on Oct 12, 2024
  9. topstop3416 commented on Apr 18, 2025

    @topstop3416

    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);
            }
        }
    }
    
  10. added theissue type on Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions