Polymorpher
The Utility Factory — Free Developer Tools
Convert, transform, beautify & decode — all in one place.
⚡ All Tools
Did You Know?
Select a tool from the sidebar to get started, or explore our free developer utilities.
About this Tool
Convert SQL to C# Classes — EF Core, POCO & Records
Transform your SQL CREATE TABLE statements into C# Entity Framework Core entities, POCO classes, or C# Records instantly. This SQL to C# converter supports full data annotation generation including [Key], [Required], [MaxLength], [Column], and [Table] attributes.
Whether you're migrating a legacy database to EF Core, generating model classes from an existing schema, or converting SQL DDL into typed C# classes — Polymorpher automates the tedious mapping work. The reverse transform converts C# classes back into SQL CREATE TABLE statements.
Supports all common SQL data types: INT, VARCHAR, NVARCHAR, DECIMAL, DATETIME, BIT, UNIQUEIDENTIFIER, TEXT, and more. 100% stateless — your SQL never leaves your browser.
Supported Output Formats
- EF Core — Full entity with data annotations
- POCO — Plain C# class with auto-properties
- Record — Immutable C# record type
Live Examples
Example 1 — Users table → EF Core entity
Input SQL:
CREATE TABLE Users ( Id INT PRIMARY KEY NOT NULL, Email NVARCHAR(255) NOT NULL, DisplayName NVARCHAR(100), CreatedAt DATETIME NOT NULL );
Output (EF Core):
[Table("Users")]
public sealed class Users
{
[Key]
public int Id { get; set; }
[Required]
[MaxLength(255)]
public string Email { get; set; }
[MaxLength(100)]
public string? DisplayName { get; set; }
[Required]
public DateTime CreatedAt { get; set; }
}
Example 2 — Products table → C# record
Input SQL:
CREATE TABLE Products ( Sku VARCHAR(50) PRIMARY KEY NOT NULL, Price DECIMAL(10,2) NOT NULL, InStock BIT NOT NULL );
Output (Record):
public sealed record Products(string Sku, decimal Price, bool InStock);
Example 3 — Reverse: EF Core → SQL DDL
Paste a C# EF Core class and get back the original CREATE TABLE statement — useful for generating migration scripts or sharing schemas with DBAs.
SQL Type Mapping Reference
| SQL Type | C# Type |
|---|---|
| INT / INTEGER | int |
| BIGINT | long |
| BIT / BOOLEAN | bool |
| DECIMAL / NUMERIC / MONEY | decimal |
| VARCHAR(n) / NVARCHAR(n) | string (nullable if no NOT NULL) |
| DATETIME / TIMESTAMP | DateTime |
| UNIQUEIDENTIFIER / UUID | Guid |
When to Use This Tool
- Migrating an existing database schema to a .NET project
- Generating EF Core models from a DBA-provided DDL script
- Quick prototyping — paste a CREATE TABLE and start coding
Limitations
- Does not generate foreign key navigation properties or
DbContextconfiguration — add relationships manually - Stored procedures, triggers, and indexes are ignored
- Custom SQL types (e.g., PostGIS geometry) map to
object
Related Tools: JSON to Code Classes · Code Beautifier · Hash Generator