Questions tagged [npgsql]

Npgsql is the .NET data provider for PostgreSQL. It allows any program developed for .NET framework to access a PostgreSQL database server. It is implemented in 100% C# code.

It allows any program developed for .NET framework to access a PostgreSQL database server. It is implemented in 100% C# code. PostgreSQL versions since 9.0 are officially supported, others may work.

Official web site: http://www.npgsql.org

Documentation: http://www.npgsql.org/doc/

2002 questions
73
votes
14 answers

.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…
mbrc
  • 3,523
  • 13
  • 40
  • 64
43
votes
10 answers

Unable to load System.Threading.Tasks.Extensions

I have a web project build on .net framework 4.5.1. We are trying to added PostgreSQL support for the project. Using Nuget, I have installed 4.0.4 npgsql to the project. Under references, I see the following being added to the project. Npgsql -…
User12111111
  • 1,179
  • 1
  • 19
  • 41
43
votes
1 answer

Postgres Npgsql Connection Pooling

I'd like to better understand Connection Pooling when using Npgsql for Postgres. (http://www.npgsql.org/) When I use the connection string: UserID=root;Password=myPassword;Host=localhost;Port=5432;Database=myDataBase;Pooling=true;Minimum Pool…
Chris
  • 3,113
  • 5
  • 24
  • 46
39
votes
3 answers

Npgsql Exception while reading from stream, Postgres

I am getting this error intermittently in my code. Sometimes it happens time-after-time-after-time. Sometimes it happens 1-out-of-10 times. I am not doing anything unique or special in my SQL unlike the other poster on StackOverflow who was doing…
RDS_JAF
  • 911
  • 1
  • 8
  • 10
35
votes
3 answers

Entity Framework Core jsonb column type

I am using Entity Framework Core with npgsql postgresql for Entity Framework Core. My question is, using migrations, how do I mark a class property to generate a JSONB column type? For example: public class MyTableClass { public int Id { get;…
bruno.almeida
  • 2,746
  • 1
  • 24
  • 32
25
votes
9 answers

Could not load file or assembly 'System.Memory, Version=4.0.1.' in Visual Studio 2015

For a couple of months i had no issue generating the model from DB by deleting it and recreating it . After a pull from git, an issue has been occurred while trying to make the same process . After the second step (connection string creation with…
Prometheus
  • 999
  • 2
  • 15
  • 28
24
votes
1 answer

'AddEntityFramework*' was called on the service provider, but 'UseInternalServiceProvider' wasn't called in the DbContext options configuration

I'm upgrading an ASP.NET Core application from Framework 2.2 to 3.1. It also uses Entity Framework Core. In the Startup.ConfigureServices method, there is this code: services.AddEntityFrameworkNpgsql() .AddDbContext(options =>…
ygoe
  • 18,655
  • 23
  • 113
  • 210
23
votes
1 answer

Connection still idle after close

I've a C# client application that need to checks a table on a Postgres db every 15 minutes. The problem is that I need to install this client into more or less 200 client so, for that I need to close the DB connection after the query. I use…
Andrea Girardi
  • 4,337
  • 13
  • 69
  • 98
21
votes
3 answers

How to tell Entity Framework that my ID column is auto-incremented (AspNet Core 2.0 + PostgreSQL)?

Code is simple. Tag.cs entity: public partial class Tag { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public string Description { get; set;…
Andrey Kotov
  • 1,344
  • 2
  • 14
  • 26
21
votes
2 answers

Configuration.GetConnectionString returns null when running asp.net core on VS Code but fine on Visual Studio

Here is my appsettings.json file { "ConnectionStrings": { "DefaultConnection": "Host=localhost;Port=5432;Database=db;User ID=postgres;Password=root" }, "Logging": { "IncludeScopes": false, "LogLevel": { "Default": "Debug", …
21
votes
1 answer

"WHERE x IN y" clause with dapper and postgresql throwing 42601: syntax error at or near \"$1\"

I have an array of strings, and I'd like to have a query containing an IN clause, like: "... WHERE t.name IN ('foo', 'bar', 'baz')..>" Here's the final bit of my query, which contains a "where X in Y" clause: ... left join genre_tag_band_join tj on…
Sava B.
  • 1,007
  • 1
  • 10
  • 21
20
votes
5 answers

How to pass parameter to sql 'in' statement?

I want to create this query: select * from products where number in ('123', '234', '456'); but I can't find any example of achiving this with Npgsql and NpgsqlParameter. I tried like this: string[] numbers = new string[] { "123", "234"…
Adrian Serafin
  • 7,665
  • 5
  • 46
  • 67
19
votes
3 answers

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. The IP address of my Azure Site Plan seemed to…
Brad Mathews
  • 1,567
  • 2
  • 23
  • 45
17
votes
1 answer

Compare field with value and return bool

I'm trying move hash cheking from server app to PostgreSQL. In other words I'm need calling a query to PGSQL, which compare string from query with string from field and return result of equal comparison as bool, but I don't know how do this without…
Arman Hayots
  • 2,459
  • 6
  • 29
  • 53
16
votes
3 answers

PostgreSQL - best way to return an array of key-value pairs

I'm trying to select a number of fields, one of which needs to be an array with each element of the array containing two values. Each array item needs to contain a name (character varying) and an ID (numeric). I know how to return an array of single…
harman_kardon
  • 1,567
  • 5
  • 32
  • 49
1
2 3
99 100