Blog icon indicating copy to clipboard operation
Blog copied to clipboard

Add Support for Postgresql

Open linkdotnet opened this issue 2 years ago • 2 comments

Add Postgresql support (for example via Entity Framework).

linkdotnet avatar Apr 28 '23 11:04 linkdotnet

Hi @linkdotnet, I would like to help you. I don't have experience acting in open-source projects, but I would like to start.

Could you give me details about the issue? It's just to add the support for Postgresql or did you try before and find incompatibilities?

diegodrf avatar Jun 22 '23 03:06 diegodrf

Hey @diegodrf - cool, help is always appreciated.

I did not try until now with PostgreSQL, but as the blog isn't using anything exotic, I don't expect much trouble here.

There are multiple ways to solve the issue. The easiest way is to use Entity Framework Provider. There you already have a repository and all the code around. See Infrastructure.

So adding the package will almost do everything for you. You just have to add the new provider in PersistenceProvider and create a new PostgreSQL extension in the RegistrationExtensions namespace.

The more complicated way is not to use Entity Framework and use something else. For this you would have to implement your own IRepository. You could have a look at how the SqlRepository does it at the moment, but that is up to you.

The general workflow looks like this:

  1. In the appsettings.json you can define your storage provider - the string has to be the same as in the PersistenceProvider class
  2. On Startup the blog checks for this and calls the StorageProviderExtensions, which you would add the new PostgreSQL type, and registers all the necessary types.
  3. The components just get injected the IRepository<T> so they don't know what underlying technology is used.

If you need more details let me know. You can also just start, open a PR and ask your questions if this is easier for you

linkdotnet avatar Jun 22 '23 05:06 linkdotnet