SQL to Entity Framework Core Converter

Convert SQL CREATE TABLE statements to Entity Framework Core C# entity classes with data annotations and DbContext.

What is SQL to Entity Framework Core Converter?

This tool converts SQL CREATE TABLE statements into Entity Framework Core C# entity classes with data annotations. It generates properly decorated classes with [Key], [Required], [MaxLength], [Column], and [Table] attributes, along with a DbContext class containing DbSet properties for each table.

How to Use

  1. Paste your SQL CREATE TABLE statements into the input area
  2. Click "Generate" to create the EF Core entity classes
  3. Review the generated C# code with data annotations
  4. Copy the output and add it to your .NET project

Why Use This Tool?

Automatically maps SQL types to C# types (int, string, bool, decimal, DateTime, Guid, etc.)
Generates [Key], [Required], [MaxLength], [Column], and [Table] data annotations
Creates a DbContext class with DbSet properties for all tables
Handles nullable reference types and default values
Supports SERIAL, UUID, JSONB, and other PostgreSQL-specific types

Tips & Best Practices

  • SERIAL columns are mapped to int with [Key] and [DatabaseGenerated(Identity)] attributes
  • Nullable SQL columns generate nullable C# types (int?, DateTime?, etc.)
  • VARCHAR and CHAR columns include [MaxLength] attributes based on type parameters
  • The generated DbContext includes placeholder connection string configuration

Frequently Asked Questions

What is Entity Framework Core?

Entity Framework Core (EF Core) is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. It maps database tables to C# classes using conventions or data annotations.

How are SQL types mapped to C# types?

INTEGER → int, BIGINT → long, VARCHAR/TEXT → string, BOOLEAN → bool, NUMERIC/DECIMAL → decimal, TIMESTAMP → DateTime, UUID → Guid, FLOAT/REAL → float/double, BYTEA/BLOB → byte[]. Nullable columns get nullable C# types.

Does it support foreign key relationships?

The current version focuses on entity class generation with data annotations. You can manually add navigation properties ([ForeignKey], [InverseProperty]) for relationships after generation.

Which database providers are supported?

The generated entities work with any EF Core provider (PostgreSQL, SQL Server, MySQL, SQLite). The column type annotations use PostgreSQL naming by default, but you can adjust them for your provider.

Is my SQL data sent to a server?

No, all processing happens entirely in your browser. Your SQL schema never leaves your device.

Related Tools