This sample demonstrates using efcpt.renaming.json to transform legacy database naming conventions (table prefixes, Hungarian notation, column prefixes) into clean, modern C# naming conventions.
Many legacy databases use naming conventions that don't translate well to C#:
| Database Name | Issue |
|---|---|
tblCustomers |
"tbl" prefix |
cust_first_name |
Column prefix + underscores |
ord_cust_id |
Abbreviated prefixes |
item_qty |
Abbreviated names |
The efcpt.renaming.json file maps these legacy names to clean C# names:
| Database | C# Entity | C# Property |
|---|---|---|
tblCustomers |
Customer |
- |
cust_first_name |
- | FirstName |
tblOrders |
Order |
- |
ord_cust_id |
- | CustomerId |
item_qty |
- | Quantity |
custom-renaming/
├── DatabaseProject/ # SQL Project with legacy-named tables
│ └── dbo/Tables/
│ ├── tblCustomers.sql
│ ├── tblOrders.sql
│ └── tblOrderItems.sql
├── EntityFrameworkCoreProject/
│ ├── EntityFrameworkCoreProject.csproj
│ ├── efcpt-config.json
│ └── efcpt.renaming.json # Renaming rules
└── CustomRenaming.sln
[
{
"SchemaName": "dbo",
"UseSchemaName": false,
"Tables": [
{
"Name": "tblCustomers",
"NewName": "Customer",
"Columns": [
{ "Name": "cust_id", "NewName": "Id" },
{ "Name": "cust_first_name", "NewName": "FirstName" }
]
}
]
}
]| Property | Description |
|---|---|
SchemaName |
Database schema (e.g., "dbo") |
UseSchemaName |
Include schema name in generated namespaces |
Tables |
Array of table renaming rules |
| Property | Description |
|---|---|
Name |
Original table name in database |
NewName |
New name for the generated entity class |
Columns |
Array of column renaming rules |
dotnet buildAfter building, the generated entities use the clean names:
// Generated from tblCustomers with renamed columns
public partial class Customer
{
public int Id { get; set; } // was: cust_id
public string FirstName { get; set; } // was: cust_first_name
public string LastName { get; set; } // was: cust_last_name
public string Email { get; set; } // was: cust_email
public string? Phone { get; set; } // was: cust_phone
public DateTime CreatedDate { get; set; } // was: cust_created_date
public bool IsActive { get; set; } // was: cust_is_active
public virtual ICollection<Order> Orders { get; set; }
}- Start incrementally - Add renaming rules for a few tables first, then expand
- Use consistent patterns - If all columns have
cust_prefix, document that pattern - Keep the renaming file in source control - It's part of your schema mapping
- Combine with inflector - Enable
use-inflectorin efcpt-config.json for automatic pluralization
{ "Name": "tblUsers", "NewName": "User" }
{ "Name": "tbl_Products", "NewName": "Product" }{ "Name": "usr_id", "NewName": "Id" }
{ "Name": "usr_email", "NewName": "Email" }{ "Name": "qty", "NewName": "Quantity" }
{ "Name": "amt", "NewName": "Amount" }
{ "Name": "desc", "NewName": "Description" }{ "Name": "first_name", "NewName": "FirstName" }
{ "Name": "created_at", "NewName": "CreatedAt" }