question

AxD avatar image
0 Votes"
AxD asked AxD answered

Where to hook in order to create SQL from model - How can I change the list of Entity Framework Core services from DbContext

I've written an EF Core extension, providing model extension methods to add user/role objects to the database. Now I need a way to create SQL statements from the model when the database is created/migrated.

So, I guess I need to replace two Entity Framework Core services (`IRelationalDatabaseCreator` and IMigrationsSqlGenerator).

How can I do this?

I don't seem to be able to modify the list of services with only a DbContext available.

dotnet-entity-framework-core
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@AxD, what do you want to replace the two Entity Framework Core services with? The article describes how to use services for your tools, you could have a look.


0 Votes 0 ·

1 Answer

AxD avatar image
0 Votes"
AxD answered

Thank you, Jack, for taking the time.

In the meantime, I worked into the EF Core 6 code and managed to find the hooks myself.

Shortly, I will be publishing an extension to EF Core for managing database users and roles by use of FluentAPI.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.