469 questions with no answers
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 ...
0
votes
0
answers
54
views
receiving system.io.ioexception when i try to connect postgresql db (using IIS)
version info.
gpdb (postgresql): 6.X
npgsql : 4.0.10
.net framework : 4.8
IIS
The issue is that when I open only one port on IIS and run the app, it works fine.
But when I open two ports, I keep ...
0
votes
0
answers
56
views
Custom primitive type collection in EF Core (8)
I have a nested entity, defined like this:
entity.OwnsOne(e => e.EncryptedElements, o =>
{
o.ToJson();
o.OwnsMany(x => x.Values, o =>
{
o.Property(x ...
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
0
answers
55
views
EF Core: Connection error to Azure PostgreSQL immediately after app startup
My mobile app sends the current location to my .NET Core app very often and a lot.
My .NET Core application using Entity Framework Core with a PostgreSQL database hosted on Azure (Flexible Server).
...
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 ...
0
votes
0
answers
141
views
How to set a custom migrations history table name using builder.AddNpgsqlDbContext<AppDbContext>() method in .NET Aspire?
I'm building a .NET Aspire-based application using PostgreSQL with Entity Framework Core. I’m registering my DbContext like this as I am using Aspire.Npgsql.EntityFrameworkCore.PostgreSQL package:
...
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
0
answers
59
views
How to convert wal log to SQL commands from given time
Postgres 14 hot standby server server is running in Debian Linux under WSL. It saves wal log from master to pg_wal directory. wal_keep size is 100 GB.
Command
pg_recvlogical -P pgoutput -o ...
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 ...
0
votes
0
answers
76
views
Database tool in Performance Profiler not working when program is pointed to PostgreSQL
My program in C# using Entity Framework Core I can point to a PostgreSQL or SQLite database. When pointed to PostgreSQL the Database tool of Performance Analyzer does not work. There only appear ...
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 ...
1
vote
0
answers
115
views
How to compare two dates with EF Core LINQ and Npgsql?
I am struggling to get documents expiring in less than 90 days:
var query = from doc in context.Documents
where doc.ExpirationDate <= DateOnly.FromDateTime(DateTime.Today.AddDays(90))
...
0
votes
0
answers
35
views
Connect ErikEJ Powertools to Google Cloud Postgres Database
Been fighting with this for some time. Normally got around this running a local copy of my database on my local machine to get around all of the Google/SSL insanity. Burned myself on at least one ...
2
votes
0
answers
95
views
Why would npgsql be throwing two different errors for timing out?
I have an ASP.NET Core Web API using EF Core. I'm trying to implement timeout middleware as shown here:
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
int ...
0
votes
0
answers
102
views
Entity Framework Core model annotation
I want to implement migrations for row level security policies in my project. The idea is to mark the model with an annotation, then intercept the generation of the migration and generate some SQL for ...
1
vote
0
answers
820
views
ASP.NET Core Identity Framework + EF Core Postgres + snake case table names
I would like to configure ASP.NET Core Identity Framework + EF Core on Postgres with lowercase snake_case table names. As it currently stands my IdentityDbContext looks like this:
using Microsoft....
1
vote
0
answers
101
views
Unnest Npgsql bulk query for integer array element
I have a integer[] slots in my PostgreSQL table and would like to use unnest to fill it in bulk.
cmd.CommandText = "INSERT INTO inventory (slots) " +
"SELECT t.slots &...
1
vote
0
answers
126
views
How do I map type NpgsqlRange<DateTime> to "tsrange" instead of "tstzrange" (default) in EF Core?
Question: How do I configure Npgsql/EF to map NpgsqlRange<DateTime> to tsrange?
I have a UDF that accepts a single argument of type tsrange:
CREATE OR REPLACE FUNCTION data.my_test(value tsrange)...
0
votes
0
answers
282
views
How can I add custom converters to Npgsql EF Core (8) traditional POCO mapping?
I need to use traditional POCO mapping to jsonb with PostgreSQL and EF Core (.net 8). The structure of those classes in fairly complex and I don't need to query them with Linq to EF. But I need to be ...
0
votes
0
answers
68
views
Batched Stored functions with parameter using npgsql in C#
I would like to know if it is possible to execute a store function using NpgsqlBatch having NpgsqlBatchCommand with parameter?
I am using Npgsql 8.0.4
Basically, it tried the following:
sql = $"...
1
vote
0
answers
159
views
How to make EF Core retry on socket error when connecting to Pgsql
I am connecting to a PostgreSQL server using EF Core and Npgsql.
Sometimes I get a System.Net.Socket.SocketException 11001 "No such host is known", and we want to treat this exception as ...
0
votes
0
answers
64
views
Conflict When use Microsoft.Extensions.DependencyInjection vs Npgsql in Net 4.8
I'm developing an application that runs on AutoCAD using .NET Framework 4.8 and Npgsql, following the MVVM pattern. In my project, I use Dependency Injection (DI) to manage the lifecycle of objects ...
0
votes
0
answers
137
views
Adding a match type to a foreign key with EF Core and Npgsql
When creating a foreign key that references multiple nullable columns in Postgresql it's possible to add a match type of "MATCH FULL" on the foreign key to ensure that all values are either ...