I’ve been developing an ASP.Net Core backend. Naturally, Entity Framework (EF) Core is used as the object-database mapper.
One cool thing about EF is that it supports many database providers: sqlite
, postgres
, mssql
, etc. Therefore, I decided to allow configuration-based provider selection. The site administrator can choose a preferred db provider in configuration:
1 | { |
Unfortunately, this is one of a few things that are, albeit documented, quite poorly described in MSDN. After spending an hour to figure out everything not mentioned in the docs, I came up with my own pattern for this, and this post is to keep a reference for myself. Hopefully, others can also benefit from this.