2,156 questions
1
vote
1
answer
375
views
Problems with EF Migrations to Postgres database using Citus
I am using EFCore migrations to alter a postgres db with the Citus extension.
I am trying the following steps with my migration:
Create the table
Call SELECT create_distributed_table etc.
Create a ...
-1
votes
1
answer
76
views
ETL process with Npgsql source suddenly started crashing
[ADO NET Source [2]] Error: Npgsql.NpgsqlException (0x80004005): Exception while reading from stream ---> System.IO.IOException: Unable to read data from the transport connection: A connection ...
0
votes
1
answer
70
views
How to query Postgresql-14 Timestamptz field in C#?
I use Postgresql-14, I have a timestamptz field named 'start_datetime' like below:
select start_datetime from table1
2023-08-01 07:00:00.000 +0700
2023-08-01 07:00:00.000 +0700
2023-08-02 07:00:00....
0
votes
1
answer
2k
views
NpgSql EntityFramework Core not persisting DateTimeOffset as UTC time in database
I'm using Npgsql.EntityFrameworkCore.PostgreSQL 7.0.4 in my console app to persist DateTimeOffset to PostgreSQL Database. However the values stored in my database are always in Local DateTimeOffset. ...
0
votes
2
answers
2k
views
C# DateTime.MinValue is handled differently by PostgreSQL, EFCore or Npgsql?
I am saving a C# DateTime.MinValue to a PostgreSQL column of type timestamp with timezone with EFCore 7.05 and Ngpsql 7.04
Date = {1/01/0001 12:00:00 AM}
Kind = Utc
When I load the column, the value ...
1
vote
1
answer
203
views
Multiple select statements using one transaction and two repositories
I just made a working Get method for Orders combining two methods:
This method gets all orders and data associated with it:
private async Task<(List<Order>, int)> ...
1
vote
1
answer
2k
views
Managing PostgreSQL connection for the best performance
I use YugabyteDB, it's compatible with PostgreSQL, so I can just use Npgsql. I have confusion with managing DbConnection. I know EntityFramework creates new connection per request, but I use Dapper ...
0
votes
2
answers
40
views
PostgreSQL Database / C# Application
I am developing a small application. I could not create the database as an idea.
My data will be as follows, should I create separate tables for them or should I use them in a single table using The ...
0
votes
0
answers
853
views
C# error 127.0.0.1:5432 that cannot connect to PostgreSQL Server
I need help on connecting to my friend's PostgreSQL server through my team's project using C# and WinForms in VS Community with Npgsql as the NuGet Package. The problem always shows when we try to ...
0
votes
1
answer
118
views
How to ignore duplicates records of a large table when using Copy Binary in postgres
I am trying to do bulk insert data in postgres using Binary copy, as below
await connection.BeginBinaryImportAsync($"COPY ph_numbers FROM STDIN (FORMAT BINARY));
This table already contains ...
1
vote
1
answer
2k
views
Entity Framework Core: remaining connection slots are reserved for non-replication superuser connections
We have a production app that is growing every day more and it is managing a lot of asynchronous requests. We had backend composed by a PostgreSQL database and an ASP.NET Core 6 Web API.
The backend ...
0
votes
2
answers
290
views
Begin Transaction Rollback
I just wanted to know what would happen if there are multiple insert and update statements like (insert into sales(),insert into saledetails(), update sale etc.) getting executed and if any exception ...
4
votes
1
answer
625
views
What is the difference between prepared statement and parameterized query in Npgsql?
I'd like to get clarification on whether parameterized queries are the same as prepared statements in Npgsql. If I write the following, without an explicit cmd.Prepare():
var cmd = new NpgsqlCommand(&...
3
votes
1
answer
393
views
How to write universal optimistic concurrency Timestamp column that works with SQL Server and with Postgresql
We need to support both databases: SQL Server and Postgresql. For optimistic concurrency we use a [Timestamp] column.
For SQL Server this code works:
public class DbEntity
{
...
[Timestamp]
...
1
vote
0
answers
60
views
Npgsql and PostgreSQL timezones issue
Warning: This software is kinda antique (PostgreSQL 10, Npgsql 2) but I intend to test it against the newer software.
The database timezone from postgresql.cof is 'GMT'.
The Windows timezone is ...
0
votes
0
answers
532
views
Npgsql in C# can not execute large queries
I have a .NET 6 C# console app connected to Denodo using Npgsql.
The main task is just to pull data with SELECT using different queries. Now I'm facing an error with one of the largest queries with ...
0
votes
0
answers
1k
views
How to get list of entities corresponding to tables in EF Core
In EF Core's derived DbContext, in the OnModelCreating(ModelBuilder modelBuilder) method, I can get all entity types defined in the model by calling modelBuilder.Model.GetEntityTypes().
My problem is ...
1
vote
1
answer
1k
views
Does NpgSql implicitly rollback a transaction that is open within a connection that is disposed
I've got a question about behaviour of NpgSql connections and transactions.
If I have an open connection that has had a transaction started on it through "BeginTransactionAsync", and I then ...
0
votes
0
answers
122
views
Entity Framework Code first is padding out strings inserted to a char field
I'm using Entity Framework to add test data to an integration database. I then read this out directly with NpgSql (easier to write PostGis queries direct in text).
One of the string properties of my ...
0
votes
1
answer
115
views
C# DbSet (Npgsql) Function property
I have a function in SQL that returns a number. This function is called some_number.
I also have a DbSet<Table>:
class Table {
public string Name { get; set; }
}
Now i want to give the ...
0
votes
0
answers
2k
views
Do I still need to use .Open() and .Close() if I already use using statement in C#?
I'm new with Npgsql, my C# Code like below:
Do I still need to use:
conn.Open();
conn.Close();
if I already use using statement?, I have try to remove it but nothing happen.
try
{
...
-1
votes
1
answer
108
views
Can't build npgsql from source
download zip from https://github.com/npgsql/npgsql
unzip
Open Npgsql.sln
Build Solution
Have many errors
1>------ Build Started: Project: Npgsql.SourceGenerators, Configuration: Debug Any CPU -----...
0
votes
1
answer
577
views
Create Postgresql enum type and binary import with Npgsql
Using Npgsql, I am trying to create a Postgresql enum type and then to do a binary import from .NET.
Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<...
0
votes
1
answer
1k
views
PostgresException: 3D000: database 'xx' does not exist
I'm attempting to run an EF migration against my PostgreSQL database using Npgsql and code that's similar to what I've used in other projects:
var applicationContextOption = CreateContextOption<...
4
votes
1
answer
2k
views
Is there a way in EF core to use a dbContext to generate migration script
Looking for a code first way of using a context to generate the sql script to migrate from one specific migration to another. I cant seem to find this online.
something like
context.Database....