2,156 questions
1
vote
0
answers
45
views
EF Core + Npgsql: "column 'status' is of type application_status but expression is of type text"
I've been struggling for two days with a PostgreSQL enum type issue in Entity Framework Core. Despite all my configuration, EF Core keeps trying to send a string (`text`) to an enum column.
The ...
1
vote
1
answer
105
views
C# NET Core LINQ To Entities doubling subquery for sorting
I am working with EF Core 6.0 Web APi.
Npgsql.EntityFrameworkCore.PostgreSQL 6.0.29
PostgreSQL 16.3
I have database (Postgres) with musical entities and lessons. Lessons related to musical entities by ...
1
vote
0
answers
36
views
DB creation fails through the Azure web app with Azure Postgres Flexible Server
I have an Azure Postgres flexible server sitting in a VNet divided into multiple subnets. In a distinct subnet lies an azure app service I am trying to run by publishing it via gitlab. However shortly ...
0
votes
1
answer
180
views
How do I use TPC to generate a sequence for each inherited entity in EF Core?
I've written a BaseEntity class which defines common fields in my database. It looks something like this:
public abstract class BaseEntity
{
[Key]
public int Id { get; set; }
public ...
0
votes
0
answers
75
views
ADO.NET failure to acquire connection in an SQL Server to PostgreSQL ETL (DTS)
I'm creating in VisualStudio for Application 2022 an ETL that is migrating data from a MS-SQL Server table to another in PostgreSQL DataBase. I create the ADO.NET Destination connection (server IP, ...
1
vote
0
answers
80
views
How does disabling `DatabaseFacade.AutoSavepointsEnabled` risk database corruption?
The code documentation for DatabaseFacade.AutoSavepointsEnabled warns that:
Setting this value to false should only be done with caution since the database could be left in a corrupted state if ...
1
vote
0
answers
40
views
How can I configure DateOnly properties that are mapped to timestamp columns so that queries use appropriate precision?
I have an AccountEntity:
public class AccountEntity
{
public int Id { get; set; }
public DateOnly? EstablishedDate { get; set; }
//...
}
which is being added via this configuration:
...
0
votes
1
answer
202
views
How to translate a custom extension method like PgContains to PostgreSQL ILIKE + unaccent in EF Core 9 with Npgsql?
I'm using Entity Framework Core 9 with PostgreSQL via Npgsql, and I frequently write the following query pattern to perform accent-insensitive and case-insensitive searches:
EF.Functions.ILike(EF....
0
votes
0
answers
315
views
No such host is known when trying to connect to Postgres from C# code
I am trying to connect to Postgres 17 in my local machine yet i'm getting an error of "No such host is known".
I established a connection to the instance through DBeaver yet doing so in code ...
1
vote
2
answers
65
views
How to pass a list of locations (longitude, latitude) to a PostgreSQL/PostGIS stored function?
I have prepared a DB fiddle for my questions and also list my SQL code below.
I have created a countries_boundaries table, which I intend to fill with .poly files provided at Geofabrik:
CREATE ...
0
votes
0
answers
73
views
The entity type is not mapped to a table - ignores ToJson call
I'm trying to follow the npgsql guide to map a class to a JSON column, but I cannot get past the following error:
System.InvalidOperationException: The entity type 'MainCategory' is not mapped to a ...
0
votes
1
answer
61
views
Keep same connection during lifetime of dbContext
I have a case where I first want to run a direct query (using .Database.SqlQuery) to try to obtain an advisory lock. Then run another query using linq. When I run the linq query, it seems it uses ...
1
vote
0
answers
47
views
Npgsql EF Core @> contains operator with a JSONB column modelled as an owned entity (.ToJson)
I have a DB entity with a JSONB column, modelled as an owned entity with .ToJson(), as recommended by the Npgsql EF Core documentation.
modelBuilder.Entity<Notification>()
.OwnsMany<...
0
votes
0
answers
81
views
Limitations of database context pooling in .NET
I have a base class called BaseDbContext. I derived two classes from this: WriteDbContext and ReadDbContext. Both contexts have compiled queries as private members in WriteDbContext and ReadDbContext:
...
1
vote
0
answers
71
views
"42883: procedure usp_delete_announcements(integer) does not exist" while calling stored procedure with out paremeters from .NET Core
I am trying to call a PostgreSQL stored procedure with OUT parameters from my .NET Core 3.1 API to delete a record based on an ID. However, when I attempt to execute the stored procedure with OUT ...
5
votes
1
answer
682
views
Polymorphism in Entity Framework Core 9 with PostgreSQL and jsonb column
I am currently working on a database table, that shall contain some base properties of the data and one property that is a jsonb column in the database that can contain different objects that are ...
0
votes
0
answers
52
views
Multi tenancy support for Single database shared schema
We are using a single database with a shared schema multi-tenancy model, as it is the most practical way to support a large number of tenants.
Is there a recommended pattern or approach in Npgsql to ...
0
votes
0
answers
58
views
Custom boolean predicate sort convention, is it possible?
We're using Hot Chocolate 14. .Net + EF Core 8, and PostgreSQL 13... I'd like to build a custom sort convention... but I haven't found any examples after scouring the internet.
The first example is ...
0
votes
1
answer
82
views
web api connection pooling
I am using the following code with npgsql 9.0.2 inside a .net 8 web api to insert records into a table, but I am having some trouble where my database gets completely overloaded with the CPU hovering ...
0
votes
0
answers
73
views
How to pass a user-defined table type (UDT) to a PostgreSQL stored procedure using C# and Npgsql?
I'm trying to pass a user-defined table type (UDT) to a PostgreSQL stored procedure using C# and Npgsql.
Here are the details - PostgreSQL composite type definition:
CREATE TYPE public....
1
vote
0
answers
35
views
Npgsql 4.1.14: call stored procedure with nullable types
I have the following PostgreSQL "function1"
function1(par1 Enum_1),
function1(par1 integer),
...
function1(par1 text)
In Npgsql V 3.2.7, the parameters could be created together with the ...
0
votes
1
answer
132
views
CREATE a stored procedure using plain query text via NpgsqlConnection::ExecuteAsync
I am trying to create a stpored procedure via Npsql from C#
private async Task TestExecute(string cmdQuery)
{
var cnnString = $"Server=localhost;User Id=admin;Password=somepass;...
0
votes
1
answer
72
views
How to pass tstzrange to postgres
Passing tstzrange to postgres in EF Core using
DateTime algus = DateTime.Parse("2024-11-25T00:00:00+02:00", CultureInfo.InvariantCulture).ToUniversalTime();
DateTime lopp = DateTime.Parse(&...
0
votes
0
answers
120
views
How to track open database connections with Entity Framework Core 8?
I have an ASP.NET Core 8 MVC application. In production the application throws an error
Npgsql.PostgresException (0x80004005): 08P01: no more connections allowed (max_client_conn)
I am using NPGSQL ...
0
votes
1
answer
164
views
In EF Core is it possible to map a `System.Version` column keeping the type's unique sorting properties?
I'd like to make a Version-backed column in the database and order by it in queries, keeping the ordering consistent with what would be the result if run on the client directly. There are many entity ...