Skip to content
Skillpedia
APIs & servers (backend)40k · #5237

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

Helps your agent migrate data access code from Oracle to PostgreSQL in .NET/C# projects. It replaces packages, rewrites connection usage, and adapts connection strings.

What it does

This code helps change a computer program from using an Oracle database to a PostgreSQL database. It adjusts the parts of the code that talk to the database.

When to use it

  • ✓When migrating a .NET project from Oracle to PostgreSQL.
  • ✓When updating database connections and commands in the code.
  • ✓To ensure data types and procedure calls work correctly with the new database.

Example of what to ask your AI

“Migrate the data access code of my .NET project from Oracle to PostgreSQL, following the migration checklist.”

Want more? Open the sections below.

How to use

The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.

Skill link

https://github.com/github/awesome-copilot/blob/main/skills/migrating-oracle-to-postgres-data-access-code/SKILL.md

Ready-to-paste message

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/migrating-oracle-to-postgres-data-access-code/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
How it works

The code replaces old Oracle packages with new ones for PostgreSQL, adjusts how the program connects to the database, and fixes differences in commands and data types between the two databases.

Installation

Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.

In the terminal (Claude Code, Codex, Cursor), in your project folder:

npx skills add github/awesome-copilot --skill migrating-oracle-to-postgres-data-access-code

Or download just the file:

curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/migrating-oracle-to-postgres-data-access-code/SKILL.md -o SKILL.md
Technical content (original SKILL.md)

Original text by the author, straight from GitHub.

Migrating .NET Data Access Code from Oracle to PostgreSQL

Migrate the C# data access layer of a single .Postgres-copy project from Oracle (Oracle.ManagedDataAccess) to PostgreSQL (Npgsql). Work item by item through Reports/{ProjectName}/MigrationChecklist.md.

Prerequisites

  • The .Postgres project copy exists (created in Phase 5 setup).
  • Reports/{ProjectName}/MigrationChecklist.md exists and is the source of truth for what to change.
  • Reports/{ProjectName}/OracleRiskAnalysis.md exists for cross-referencing behavioral differences.

Workflow

Progress:
- [ ] Step 1: Replace NuGet packages
- [ ] Step 2: Update connection string configuration
- [ ] Step 3: Rewrite ADO.NET type references
- [ ] Step 4: Fix DbType mappings
- [ ] Step 5: Migrate stored procedure invocation
- [ ] Step 6: Address Oracle-specific SQL and syntax
- [ ] Step 7: Build and verify

Step 1: Replace NuGet packages

In the .csproj of the .Postgres project:

  • Remove: Oracle.ManagedDataAccess.Core, Oracle.EntityFrameworkCore (and any other Oracle.* packages)
  • Add: Npgsql (for ADO.NET) and/or Npgsql.EntityFrameworkCore.PostgreSQL (for EF Core)
  • Keep version pinning consistent with the target .NET version; do not introduce newer package versions than what the solution already uses for similar packages.
  • If System.Data abstractions (IDbConnection, IDbCommand) are used project-wide, the surface-level code may need fewer changes — identify them first.

Step 2: Update connection string configuration

  • Locate the Oracle connection string in appsettings.json, appsettings.{env}.json, web.config, app.config, or environment variable configuration.
  • Replace with a Npgsql-compatible connection string: Host=localhost;Port=5432;Database=mydb;Username=myuser;Password=mypassword
  • Do not hardcode credentials — use the same configuration mechanism already in use (e.g., environment variables, secrets manager, IConfiguration).
  • Update any named connection string keys only if they were Oracle-specific (e.g., OracleConnection). Prefer keeping the same key name to minimize application config changes.

Step 3: Rewrite ADO.NET type references

Replace Oracle-specific ADO.NET types with Npgsql equivalents:

Oracle type Npgsql replacement
OracleConnection NpgsqlConnection
OracleCommand NpgsqlCommand
OracleDataReader NpgsqlDataReader
OracleDataAdapter NpgsqlDataAdapter
OracleParameter NpgsqlParameter
OracleTransaction NpgsqlTransaction
OracleException NpgsqlException
OracleDbType NpgsqlDbType (from NpgsqlTypes namespace)

Update using directives accordingly (using Oracle.ManagedDataAccess.Client → using Npgsql).

If the codebase uses IDbConnection/IDbCommand abstractions registered via DI, update only the DI registration and connection string — the consuming code may not need changes.

Step 4: Fix DbType and NpgsqlDbType mappings

Oracle parameter types do not map 1:1 to Npgsql. Review every OracleParameter (now NpgsqlParameter) that sets an explicit type:

Oracle type Notes
OracleDbType.Varchar2 Use NpgsqlDbType.Varchar or omit (Npgsql infers from value)
OracleDbType.Clob Use NpgsqlDbType.Text
OracleDbType.Number Use NpgsqlDbType.Numeric or NpgsqlDbType.Integer depending on precision
OracleDbType.Date Use NpgsqlDbType.Date (date only) or NpgsqlDbType.Timestamp (if time component used)
OracleDbType.TimeStamp Use NpgsqlDbType.Timestamp
OracleDbType.RefCursor Use NpgsqlDbType.Refcursor — see Step 5
OracleDbType.Char Use NpgsqlDbType.Char

For parameters where Oracle inferred the type from the value, Npgsql also infers — explicit type setting is often unnecessary and can be removed.

Step 5: Migrate stored procedure invocation

Oracle and PostgreSQL stored procedure invocation differ significantly:

  • Command type: Retain CommandType.StoredProcedure for function calls. For procedures that use OUT parameters, PostgreSQL requires CommandType.Text with CALL proc_name(...) syntax in some versions of Npgsql — verify against the target Npgsql version.
  • RefCursor handling: Oracle returns ref cursors as output parameters; PostgreSQL returns them differently:
    • For RETURNS TABLE / RETURNS SETOF, use ExecuteReader() directly — no cursor parameter needed.

…

FAQ

What are NuGet packages?

They are like 'toolboxes' that add extra features to your program. This code swaps the Oracle toolboxes for PostgreSQL ones.

What is a connection string?

It's like the address and credentials the program uses to find and access the database. The code updates this address for the new PostgreSQL database.

Why do data types need fixing?

Different databases understand data types (like text, numbers, dates) slightly differently. The code makes sure the correct types are used in PostgreSQL.

Details

Original description by the author

Migrates .NET/C# data access code from Oracle to PostgreSQL (Npgsql). Replaces Oracle NuGet packages, rewrites OracleConnection/OracleCommand/OracleDataReader usage, fixes DbType mappings, updates stored procedure invocation patterns, and adapts connection string configuration. Use when migrating the application code layer of a .NET project during an Oracle-to-PostgreSQL database migration.

repo: github/awesome-copilot

Popularity

GitHub stars
40k
Ranking position
#5237
License
MIT
Updated
10/15/2026

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills