-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
Add Support for Postgresql #207
Comments
Hi @linkdotnet, I would like to help you. 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? |
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 The general workflow looks like this:
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 |
Hello there, Is this issue still open today I discovered this project |
There were some attempts but this is currently open and up for grabs if you like to tackle it. |
Thanks for the reply, I will take a look during the weekend and my free time and use the earlier comment details you wrote. |
Thanks - if you have any question, just start shooting ;) |
question, for support of postgresql do I aim with net 9.0 or any specific version? |
|
Thanks will update my devenv with both and do a fork of the repo and another question do I keep using this issue thread about Postgre or I go with new one? |
I would keep them here if they are related. Maybe it helps others as well. |
Hello, on my fork I was able to include support for PostgreSQL, I can build and run but found this exception when trying to save a blog into the DB it comes from
Microsoft.EntityFrameworkCore.DbUpdateException
HResult=0x80131500
Message=An error occurred while saving the entity changes. See the inner exception for details.
Source=Microsoft.EntityFrameworkCore.Relational
StackTrace:
at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.d__50.MoveNext()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.d__9.MoveNext()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.d__9.MoveNext()
at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.d__9.MoveNext()
at Microsoft.EntityFrameworkCore.Storage.RelationalDatabase.d__8.MoveNext()
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.d__111.MoveNext()
at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.d__115.MoveNext()
at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.d__7`2.MoveNext()
at Microsoft.EntityFrameworkCore.DbContext.d__63.MoveNext()
at Microsoft.EntityFrameworkCore.DbContext.d__63.MoveNext()
at LinkDotNet.Blog.Infrastructure.Persistence.Sql.Repository`1.d__7.MoveNext() in F:\Dev\CSharp\Blog\src\LinkDotNet.Blog.Infrastructure\Persistence\Sql\Repository.cs:line 93
at LinkDotNet.Blog.Infrastructure.Persistence.Sql.Repository`1.d__7.MoveNext() in F:\Dev\CSharp\Blog\src\LinkDotNet.Blog.Infrastructure\Persistence\Sql\Repository.cs:line 93
at LinkDotNet.Blog.Infrastructure.Persistence.CachedRepository`1.d__7.MoveNext() in F:\Dev\CSharp\Blog\src\LinkDotNet.Blog.Infrastructure\Persistence\CachedRepository.cs:line 52
at LinkDotNet.Blog.Web.Features.Admin.BlogPostEditor.CreateBlogPost.d__1.MoveNext() in F:\Dev\CSharp\Blog\src\LinkDotNet.Blog.Web\Features\Admin\BlogPostEditor\CreateBlogPost.razor:line 14
at Microsoft.AspNetCore.Components.ComponentBase.d__30.MoveNext()
This exception was originally thrown at this call stack: Inner Exception 1: Error ExceptionThe error happens because Npgsql changed his behavior of mapping Date and time creating a breaking change: So it requires to use this line of code to use the legacy behavior
Or to update with the new mapping or use their NodaTime Plugin: https://www.npgsql.org/doc/types/nodatime.html?tabs=datasource |
Hey @EliasMasche, Thanks for the update. Hmm I see the problem. Well, there are two ways of solving this.
I do think the latter one, is the way to go. |
Another issue that can and will show up with local (server) time is that in my case, I have different servers(on-premise and cloud) in different timezones, so if I migrate or restore a backup, it will provoke issues with different times. How it will work using migration with |
Basically the But for now - saving everything as UTC is the best option (both of these values). Maybe some adoptions in the background services have to be made as well and how this information is presented to the user. But I can take over that part. |
So I create a PR with the initial support of PostgreSQL and from there you continue with the necessary changes? |
Indeed. The changes will be small, so that is absolutely fine. |
Created the PR |
Done by @EliasMasche in #399 |
Add Postgresql support (for example via Entity Framework).
The text was updated successfully, but these errors were encountered: