Langsung ke konten
Skillpedia
API & server (backend)40k Β· #7294

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

Fungsinya

Kode ini membantu memindahkan program komputer dari database Oracle ke database PostgreSQL. Kode ini menyesuaikan bagian-bagian program yang berhubungan dengan database.

Kapan dipakai

  • βœ“Saat memigrasikan proyek .NET dari Oracle ke PostgreSQL.
  • βœ“Saat memperbarui koneksi dan perintah database di dalam kode.
  • βœ“Untuk memastikan tipe data dan pemanggilan prosedur berfungsi dengan benar pada database yang baru.

Link skill

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

Salin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.

Cara pakai

Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.

Pesan siap tempel

Gunakan skill ini untuk membantu saya: https://github.com/github/awesome-copilot/blob/main/skills/migrating-oracle-to-postgres-data-access-code/SKILL.md Baca file SKILL.md di link tersebut dan ikuti instruksinya untuk tugas saya.
Mau AI Anda menemukan skill seperti ini sendiri?Pasang MCP Skillpedia gratis: cukup satu baris, dan AI mencari di antara 15.000+ skill sebelum tiap tugas.Pasang dalam 1 menit β†’

Contoh permintaan ke AI

β€œMigrasikan kode akses data proyek .NET saya dari Oracle ke PostgreSQL, ikuti checklist migrasi.”

5 skill baru setiap minggu. 1 menit baca.

Cara kerjanya

Kode ini mengganti package Oracle lama dengan package baru untuk PostgreSQL, menyesuaikan cara program terhubung ke database, dan memperbaiki perbedaan perintah serta tipe data antara kedua database.

Konten teknis (SKILL.md asli)

Teks asli dari pembuat, dalam bahasa Inggris, langsung dari 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.

…

Pertanyaan umum

Apa itu NuGet packages?

NuGet packages ibarat 'kotak perkakas' yang menambahkan fitur ekstra ke program Anda. Kode ini menukar kotak perkakas Oracle dengan kotak perkakas untuk PostgreSQL.

Apa itu connection string?

Connection string ibarat alamat dan kredensial yang digunakan program untuk menemukan dan mengakses database. Kode ini memperbarui alamat tersebut agar mengarah ke database PostgreSQL.

Mengapa tipe data perlu diperbaiki?

Setiap database memahami tipe data (seperti teks, angka, dan tanggal) dengan sedikit berbeda. Kode ini memastikan tipe data yang benar digunakan di PostgreSQL.

Detail

Deskripsi asli dari pembuat

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

Popularitas

Bintang GitHub
40k
Peringkat
#7294
Lisensi
MIT
Diperbarui
15/10/2026

Apakah skill ini berguna?

0

Masuk untuk memberi suara.

Komentar

  • …

Skill lain dari repositori ini

Skill serupa