Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Make sure the migrations history table is created cleanly #16026

Closed
ajcvickers opened this issue Jun 10, 2019 · 5 comments
Closed

Make sure the migrations history table is created cleanly #16026

ajcvickers opened this issue Jun 10, 2019 · 5 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.

Comments

@ajcvickers
Copy link
Contributor

The issue is that now that we discover DbSets from a context as a convention, re-using the convention-laden ModelBuilder for creating the history table also brings in types from the context.

For now, the fix merged is to remove this convention, but we may want to consider other options for building the history table.

See #16024

@bricelam
Copy link
Contributor

Oh weird. I wouldn’t expect this to reference a DbContext:

var conventionSet = ConventionSetBuilder.CreateConventionSet();

How do you get a convention set for building a model outside of the DbContext?

@ajcvickers
Copy link
Contributor Author

@bricelam Typically you get it explicitly for the provider you are using. For example:

var conventionSet = SqlServerConventionSetBuilderf.Build();

On the other hand, the one you get from D.I. is fully configured with everything for the context, including provider conventions, any plugged-in conventions (such as for proxies), and now conventions based on the DbContext type being used.

/cc @AndriySvyryd

@AndriySvyryd
Copy link
Member

When #214 is implemented it will be easy to customize the conventions returned by ConventionSetBuilder.CreateConventionSet(), so we shouldn't use it for the history table.
At the same time #214 will introduce convention groups, so it would be possible to do something like ConventionSetBuilder.CreateConventionSet(ConventionGroup.AllExceptContextDependent)

@ajcvickers ajcvickers added this to the Backlog milestone Jun 14, 2019
@AndriySvyryd AndriySvyryd self-assigned this Sep 1, 2020
@ajcvickers ajcvickers modified the milestones: Backlog, 6.0.0 Nov 5, 2020
@ajcvickers ajcvickers modified the milestones: 6.0.0, Backlog Sep 1, 2021
@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Nov 10, 2021
@ajcvickers ajcvickers modified the milestones: 7.0.0, Backlog Sep 2, 2022
@ajcvickers ajcvickers added the punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints. label Sep 2, 2022
@ajcvickers
Copy link
Contributor Author

Current code is:

            var conventionSet = Dependencies.ConventionSetBuilder.CreateConventionSet();

            conventionSet.Remove(typeof(DbSetFindingConvention));
            conventionSet.Remove(typeof(RelationalDbFunctionAttributeConvention));

This seems fine.

@ajcvickers ajcvickers removed this from the Backlog milestone Dec 8, 2023
@ajcvickers
Copy link
Contributor Author

Note from triage: this could take advantage of convention classes when available, but it does not need to.

@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Jan 4, 2024
@ajcvickers ajcvickers added closed-no-further-action The issue is closed and no further action is planned. and removed type-bug area-migrations labels Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. punted-for-6.0 punted-for-7.0 Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
Projects
None yet
Development

No branches or pull requests

3 participants