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

Enable compositional approach of custom migration functionality #17740

Open
Tracked by #22945
taori opened this issue Sep 10, 2019 · 3 comments
Open
Tracked by #22945

Enable compositional approach of custom migration functionality #17740

taori opened this issue Sep 10, 2019 · 3 comments

Comments

@taori
Copy link

taori commented Sep 10, 2019

Problem

I just read this article : https://docs.microsoft.com/de-de/ef/core/managing-schemas/migrations/operations

Reading the details about how to implement the generator objects for custom migration functionality it appears to me, that you can only extend migration functionality by overwriting existing one.

protected override void OnConfiguring(DbContextOptionsBuilder options)
    => options
        .UseSqlServer(connectionString)
        .ReplaceService<IMigrationsSqlGenerator, MyMigrationsSqlGenerator>();

Solution

If a compositional approach of this were to exist it would be possible to write many packages which extend the functionality of the MigrationBuilder, which seems like a much better alternative?

@bricelam
Copy link
Contributor

I like it. We have a few other places where we enable composition using services called plugins. This seems to be a good fit for the same pattern.

@taori
Copy link
Author

taori commented Sep 13, 2019

How would this usually be implemented though in this case?

Overwriting the generator completely and providing this feature in an extensible way instead would always in some fashion break user code in order to work, no?

The possibilities it opens up are endless though.

@bricelam
Copy link
Contributor

We’d add a new service type like IMigrationsSqlGeneratorPlugin. You could add multiple of these. If the main generator didn’t handle an operation (or maybe before it tried to) it would see if there was a plug-in that could

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

No branches or pull requests

4 participants