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 ...
0
votes
0
answers
153
views
WCF + PostgresQL. Npqsql connection is not open
I'm creating a client-server chat application using WCF. To connect I use the same code as for my other app, but it doesn't work here.
This is part of my Code
Client:
private void bReg_Click(object ...
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
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
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 ...
24
votes
4
answers
37k
views
Azure Postgres: no pg_hba.conf entry for host "0.0.0.0", user "UserName", database "orders", SSL on
I have an Azure website in development that connects to a new Azure Postgresql database.
This error seemed to have started over the weekend. It was working fine the last time I tried it on Friday. ...
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
91
views
How to resolve EF Core continuous migration error with npgsql HiLo?
I'm using Hilo with a custom sequence name. When creating migrations, EF Core always creates a migration to drop the sequence with the normal name. Since EF Core 9.0, this produces a runtime exception ...
6
votes
1
answer
14k
views
Exception while reading from stream in npgsql
We have a table having one of the columns as a text datatype and having only 3 records. We execute an Update query on text column using ExecuteNonQuery() and it throws an error "Exception while ...
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 ...
1
vote
1
answer
777
views
Random Npgsql Connection Timeout in .net6 Application
I have this piece of code in program.cs to initialize my pool with 5 connections in my .net6 application using postgres and Npgsql.
List<NpgsqlConnection> connections = new List<...
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, ...
114
votes
15
answers
177k
views
.NET6 and DateTime problem. Cannot write DateTime with Kind=UTC to PostgreSQL type 'timestamp without time zone'
I have common problem.
Cannot write DateTime with Kind=UTC to PostgreSQL type 'timestamp
without time zone'
And I want to enable Legacy Timestamp behavoour as is documented here:
https://github.com/...
0
votes
1
answer
51
views
Should order of columns in index match order of columns in query?
We are using EF Core 8.0 with the Npgsql provider. We have several entities that look similar to this:
public class Foo
{
public Guid TenantId { get; set; }
public Guid FooId { get; set; }
}
...
12
votes
9
answers
26k
views
update-database: host can't be null error
I have recently installed the EF Core 3.1.6 on a home project using postgresql.
I have the connection string, and can add migrations easily with the Package Manager Console. If I run my application ...
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:
...
1
vote
1
answer
97
views
npgsql call jsonb_path_exists on string mapped jsonb
I've got a table with the filed string Data { get; set; } of type jsonb:
modelBuilder.Entity<LayoutEntity>(b =>
{
b.Property(p => p.Data).IsRequired().HasColumnName("data")....
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:
...
1
vote
1
answer
639
views
Problem with Code-First Database and PostgreSql
I am using Code-First project and my database is PostgreSql. When I migrated my project to PostgreSql by using Npgsql v.2.2.7 everything worked fine. I need to use the new version of Npsql. To achieve ...
0
votes
1
answer
126
views
How to get single row of values from database
Reading multiple values from a Postgres database using npgsql and EF Core in an ASP.NET Core MVC view:
var tulem = await ctx.Database
.SqlQuery<(string Klient, int Krediit, int ...
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 ...
6
votes
3
answers
13k
views
Npgsql.PostgresException: Column cannot be cast automatically to type bytea
Using EF-Core for PostgresSQL, I have an entity with a field of type byte but decided to change it to type byte[]. But when I do migrations, on applying the migration file generated, it threw the ...
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:
...