migrating-oracle-to-postgres-data-access-code

Migrates .NET data access code from Oracle to PostgreSQL using Npgsql.

38.5k|4.9k|Updated Jun 11, 2025
One-click install
npx skills add https://github.com/github/awesome-copilot --skill migrating-oracle-to-postgres-data-access-code
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrating-oracle-to-postgres-data-access-code
Source: https://github.com/github/awesome-copilot/tree/main/skills/migrating-oracle-to-postgres-data-access-code
Command: npx skills add https://github.com/github/awesome-copilot --skill migrating-oracle-to-postgres-data-access-code

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Migrating a .NET application's data access layer from Oracle to PostgreSQL involves dozens of subtle incompatibilities—ADO.NET type replacements, DbType mappings, stored procedure invocation differences, and Oracle-specific SQL syntax—that are easy to miss and cause runtime failures.

Core Features & Use Cases

  • NuGet and ADO.NET Migration: Replaces Oracle.ManagedDataAccess packages with Npgsql and rewrites OracleConnection/OracleCommand/OracleDataReader usage with Npgsql equivalents.
  • Type and Procedure Mapping: Converts OracleDbType to NpgsqlDbType mappings and rewrites stored procedure calls, including RefCursor handling and OUT parameter patterns.
  • SQL Syntax Conversion: Replaces Oracle-specific constructs like ROWNUM, NVL, DECODE, DUAL, CONNECT BY, and MERGE INTO with PostgreSQL equivalents.
  • Use Case: A team migrating an enterprise .NET application to PostgreSQL uses this Skill to systematically work through a migration checklist on the .Postgres project copy, fixing compilation errors and verifying no Oracle references remain.

Quick Start

Migrate the data access layer of my .Postgres project from Oracle to PostgreSQL following the MigrationChecklist.md in the Reports folder.

Frequently Asked Questions about migrating-oracle-to-postgres-data-access-code

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate .NET data access code from Oracle to PostgreSQL?

Replace Oracle.ManagedDataAccess packages with Npgsql, rewrite OracleConnection/OracleCommand types to Npgsql equivalents, fix DbType mappings, and update stored procedure calls. This Skill works through a MigrationChecklist.md item by item and verifies with dotnet build.

How to replace OracleConnection with NpgsqlConnection in C#?

Swap Oracle ADO.NET types for Npgsql equivalents: OracleConnection becomes NpgsqlConnection, OracleCommand becomes NpgsqlCommand, and update using directives from Oracle.ManagedDataAccess.Client to Npgsql. Code using IDbConnection abstractions may only need DI registration changes.

Does Npgsql support Oracle RefCursor output parameters?

Npgsql handles cursors differently than Oracle. For RETURNS TABLE or SETOF functions, use ExecuteReader directly. For RETURNS refcursor, call within a transaction, read the cursor name from the output parameter, then issue FETCH ALL IN with the cursor name.

What Oracle SQL syntax breaks when migrating to PostgreSQL?

ROWNUM must become LIMIT, NVL becomes COALESCE, DECODE becomes CASE WHEN, DUAL is removed, CONNECT BY requires recursive CTEs, and MERGE INTO becomes INSERT ON CONFLICT. Also note PostgreSQL does not treat empty strings as NULL like Oracle does.

Can I migrate EF Core from Oracle to PostgreSQL?

Yes, replace Oracle.EntityFrameworkCore with Npgsql.EntityFrameworkCore.PostgreSQL and change UseOracle to UseNpgsql in the DbContext configuration. Review OnModelCreating for Oracle-specific column types, but do not run EF migrations if schema is managed externally.