Skip to content

Misleading error message when type registration is missing for NpgsqlDbType parameters (error says check the database, but the problem is in type registration in the ADO.net level) #4795

@rwasef1830

Description

@rwasef1830

Steps to reproduce

  1. create database something;
  2. create extension postgis;
  3. create tablespace
  4. alter database set tablespace new
  5. alter database set tablespace pg_default;
  6. Launch project that connects to this database.

The issue

Exception message:
Npgsql.NpgsqlException (0x80004005): The NpgsqlDbType 'Geography' isn't present in your database. You may need to install an extension or upgrade to a newer version.

Stack trace:
 at Npgsql.TypeMapping.TypeMapper.ResolveByNpgsqlDbType(NpgsqlDbType npgsqlDbType)
   at Npgsql.NpgsqlParameter.ResolveHandler(TypeMapper typeMapper)
   at Npgsql.NpgsqlBinaryImporter.Write[T](T value, NpgsqlParameter param, Boolean async, CancellationToken cancellationToken)

Further technical details

Npgsql version: 7.0.0
PostgreSQL version: 15.1 with postgis
Operating system: Windows 11

Other details about my project setup:
The code that triggers this is a script which uses the binary importer to bulk load some data. This was working fine before, the only thing that changed between it working and not working is changing the tablespace then changing it back to pg_default.

\dT geography:
List of data types
+--------+-----------+------------------------------------------------------------------------------------------------------+
| Schema | Name | Description |
+--------+-----------+------------------------------------------------------------------------------------------------------+
| public | geography | postgis type: The type representing spatial features with geodetic (ellipsoidal) coordinate systems. |
+--------+-----------+------------------------------------------------------------------------------------------------------+
(1 row)

I'm confused, I have no idea what is wrong or why/how did this break.

CREATE EXTENSION postgis:
ERROR: 42710: extension "postgis" already exists
LOCATION: CreateExtension, extension.c:1729
Time: 2.002 ms

alter extension postgis update;
NOTICE: 00000: version "3.3.2" of extension "postgis" is already installed
LOCATION: ExecAlterExtensionStmt, extension.c:3006
ALTER EXTENSION

I feel like I'm getting gaslit. If I try to drop the extension, it says objects depend on it. It's definitely 100% there.
The connection string in my app was not touched.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions