Skip to content

OnConfiguring no longer has condition to check !optionsBuilder.IsConfigured #30168

Closed as not planned

Description

@dcitak

After upgrading from EF Core 6 something to 7, it appears that scaffolding removes the condition in OnConfiguring - "if (!optionsBuilder.IsConfigured)" is no longer there. This causes the connection string that was used for scaffolding to always be used regardless of what is passed in for the options when setting up EF in program.cs in a web api for example. I know there is the --no-onconfiguring option but I was not using that with EF 6.

Was this intentional? If so, should it be considered a breaking change?

Activity

  1. ajcvickers commented on Jan 29, 2023

    @ajcvickers
    Contributor

    This is by-design. The change is discussed here: ErikEJ/EFCorePowerTools#1647 (comment)

  2. dcitak commented on Jan 30, 2023

    @dcitak
    Author

    Thanks. Good to know. This would have been a breaking change for me if I had not noticed it.

    There is a large discussion on the same thing here. Somewhere there I think is when the condition was added:

    #10432

  3. mhkolk commented on Mar 1, 2023

    @mhkolk

    Oh god, some really messed up thinking in here. A couple of reasons why this was a terrible decision:

    1. configuring context the way it used to work prior to EF Core 7 was used for years
    2. the option you are referring to is obscure and almost nobody knows about it
    3. most ASP.NET Core MS docs and community tutorials talk about providing the configuration through OnConfiguring and the DbContextOptionsBuilder instance
    4. you failed to change the docs I just mentioned (a slew of ASP.NET Core/Worker apps/Console apps docs
    5. you failed to document the change as a breaking change.

    This is not the first time it seems as though the EF team lives in its own bubble, ignorant of other .NET parts.

    The result: globally and universally wasted developer time.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions