You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Improve documentation on how to write an EF Core provider #681
The mechanics of adding provider specific extension methods
Whether this should be in a blog post or if it needs to be part of the documentation is something we can discuss, but I would be inclined to have it in the actual documentation.
Reacted by InDieTasten, Mahan Mawadj, Belisarith, Philip Miller, paule96, Tomáš Hübelbauer, Nico Gallinal, Olivier MATROT, VERNOU Cédric, Tom and 19 more
You could also take a look at FileBaseContext which is probably one of the simpler providers out there. Maybe @dualbios can provide some tips on creating a provider from scratch.
@DaveRMaltby I'm not quite sure what you mean with "may allow most of the specific database logic for anyone who needs to create an EF Core provider to be placed in their own ADO.NET data provider and then use this template repo to get most of the way there very quickly"; there's typically various database-specific logic that has to go into each EF provider, which does not belong in the lower-level ADO.NET provider (e.g. how to produce various SQL constructs). The idea of "general ADO.NET-compatible EF provider" which would somehow just work with any ADO.NET provider simply doesn't work.
I think the main value in a template here would be to have a minimal provider sample which implements the services that must be overridden (or would typically be overridden for most providers). This would only provide a starting point for new providers, or for understanding how a provider looks like.
Note also that a minimal relational (ADO.NET-based) EF provider looks very different from a non-relational provider; for example, a relational EF provider typically needs to have its version of QuerySqlGenerator, which non-relational provider obviously don't need. I agree it's worth concentrating on a relational template; non-relational providers in general can be extremely different based on the database being targeted, and there's not likely to be a lot of commonality there.
@roji and @ErikEJ, I didn't forget about this. I have finally completed what I was referring to above. I have taken and built a custom EF Core provider that depends on a SQLite ADO.NET provider. Of course, I knew that there would be some custom code that is unique to support the SQLite provider, but it doesn't seem that much as you can see in MyCustom EF Core provider repo.
See what yáll think. Look at the README for this repo. I've tried to logically break up what is needed into 4 steps. The basic unit tests are passing for me.
Note: It builds against EF Core 6.x, but I only did that because currently my product is using that version. If/when you want to add this into an EF Core repo, of course we'll rev it up to the latest version.
Anyhow, let me know if you want more of my involvement here. For my company's use, I have 4 providers to implement and will be working on those efforts, unless you need something further here. Thanks for the guidance!
So is it a correct statement that the critical part is working outwards from the ...ServiceCollectionExtensions classes' "IServiceCollection AddEntityFramework..." section, and create your versions of those classes listed there as needed? And that InMemoryServiceCollectionExtensions.cs or CosmosServiceCollectionExtensions.cs is the version probably close to the minimum needed to implement?
So is it a correct statement that the critical part is working outwards from the ...ServiceCollectionExtensions classes' "IServiceCollection AddEntityFramework..." section, and create your versions of those classes listed there as needed? And that InMemoryServiceCollectionExtensions.cs or CosmosServiceCollectionExtensions.cs is the version probably close to the minimum needed to implement?
Honestly, I'm still not an expert and got a lot of guidance from ChatGPT. I asked it to indicate the minimal classes required. Anyhow, the ServiceCollectionExtensions class does register your provider services that the Entity Framework will use via DI for itself. It is only your DbContext derived classes (BloggingContext in my unit tests) that end up kicking off the framework to do things using your provider registered services. Anyhow, this was the minimal classes that I found was need to get the GettingStartedTests running with the SQLite in-memory ADO.NET provider. Note: This hasn't been reviewed by @roji and @ErikEJ as far as know, so this example may be missing things.
Activity
44 remaining items
mguinness commentedon Feb 6, 2023
You could also take a look at FileBaseContext which is probably one of the simpler providers out there. Maybe @dualbios can provide some tips on creating a provider from scratch.
roji commentedon Feb 12, 2023
@DaveRMaltby I'm not quite sure what you mean with "may allow most of the specific database logic for anyone who needs to create an EF Core provider to be placed in their own ADO.NET data provider and then use this template repo to get most of the way there very quickly"; there's typically various database-specific logic that has to go into each EF provider, which does not belong in the lower-level ADO.NET provider (e.g. how to produce various SQL constructs). The idea of "general ADO.NET-compatible EF provider" which would somehow just work with any ADO.NET provider simply doesn't work.
I think the main value in a template here would be to have a minimal provider sample which implements the services that must be overridden (or would typically be overridden for most providers). This would only provide a starting point for new providers, or for understanding how a provider looks like.
Note also that a minimal relational (ADO.NET-based) EF provider looks very different from a non-relational provider; for example, a relational EF provider typically needs to have its version of QuerySqlGenerator, which non-relational provider obviously don't need. I agree it's worth concentrating on a relational template; non-relational providers in general can be extremely different based on the database being targeted, and there's not likely to be a lot of commonality there.
DaveRMaltby commentedon May 9, 2023
@roji and @ErikEJ, I didn't forget about this. I have finally completed what I was referring to above. I have taken and built a custom EF Core provider that depends on a SQLite ADO.NET provider. Of course, I knew that there would be some custom code that is unique to support the SQLite provider, but it doesn't seem that much as you can see in MyCustom EF Core provider repo.
See what yáll think. Look at the README for this repo. I've tried to logically break up what is needed into 4 steps. The basic unit tests are passing for me.
Note: It builds against EF Core 6.x, but I only did that because currently my product is using that version. If/when you want to add this into an EF Core repo, of course we'll rev it up to the latest version.
Anyhow, let me know if you want more of my involvement here. For my company's use, I have 4 providers to implement and will be working on those efforts, unless you need something further here. Thanks for the guidance!
JohnGoldInc commentedon May 13, 2023
So is it a correct statement that the critical part is working outwards from the ...ServiceCollectionExtensions classes' "IServiceCollection AddEntityFramework..." section, and create your versions of those classes listed there as needed? And that InMemoryServiceCollectionExtensions.cs or CosmosServiceCollectionExtensions.cs is the version probably close to the minimum needed to implement?
DaveRMaltby commentedon May 13, 2023
Honestly, I'm still not an expert and got a lot of guidance from ChatGPT. I asked it to indicate the minimal classes required. Anyhow, the ServiceCollectionExtensions class does register your provider services that the Entity Framework will use via DI for itself. It is only your DbContext derived classes (BloggingContext in my unit tests) that end up kicking off the framework to do things using your provider registered services. Anyhow, this was the minimal classes that I found was need to get the GettingStartedTests running with the SQLite in-memory ADO.NET provider. Note: This hasn't been reviewed by @roji and @ErikEJ as far as know, so this example may be missing things.
ThaDaVos commentedon Jul 11, 2026
So any idea when the docs get updated?
roji commentedon Jul 12, 2026
I'd highly recommend using AI to explore things rather than waiting for documentation on this topic.
ThaDaVos commentedon Jul 12, 2026
Maybe you should use AI to fix the docs then...
anasik commentedon Aug 15, 2026
I wrote a successor to @ajcvickers original post that's featured in the docs and I would like it to be featured the same way.
Here it is: https://anasismail.com/so-you-still-want-to-write-an-ef-core-provider/
Let me know if I am allowed to make a PR with this?
@AndriySvyryd
AndriySvyryd commentedon Aug 17, 2026
@anasik Sure