본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)40k · #7294

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

하는 일

이 코드는 프로그램이 Oracle 데이터베이스 대신 PostgreSQL 데이터베이스를 쓰도록 바꾸는 데 도움을 줍니다. 데이터베이스와 통신하는 코드 부분을 조정합니다.

사용하는 경우

  • ✓.NET 프로젝트를 Oracle에서 PostgreSQL로 옮길 때.
  • ✓코드의 데이터베이스 연결과 명령을 업데이트할 때.
  • ✓새 데이터베이스에서 데이터 형식과 프로시저 호출이 제대로 작동하도록 할 때.

스킬 링크

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

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

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.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“마이그레이션 체크리스트를 따라, 내 .NET 프로젝트의 데이터 접근 코드를 Oracle에서 PostgreSQL로 옮겨 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

코드는 기존 Oracle 패키지를 PostgreSQL용 새 패키지로 바꾸고, 프로그램이 데이터베이스에 연결하는 방식을 조정합니다. 두 데이터베이스 사이의 명령과 데이터 형식 차이도 고칩니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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.

…

자주 묻는 질문

NuGet 패키지는 무엇인가요?

프로그램에 추가 기능을 더하는 '도구 상자'와 같습니다. 이 코드는 Oracle 도구 상자를 PostgreSQL 도구 상자로 바꿉니다.

연결 문자열은 무엇인가요?

프로그램이 데이터베이스를 찾고 접근할 때 쓰는 주소와 인증 정보와 같습니다. 이 코드는 새 PostgreSQL 데이터베이스를 위해 이 주소를 업데이트합니다.

데이터 형식은 왜 고쳐야 하나요?

데이터베이스마다 텍스트, 숫자, 날짜 같은 데이터 형식을 조금씩 다르게 이해합니다. 이 코드는 PostgreSQL에서 올바른 형식을 쓰도록 합니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
40k
순위
#7294
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬