Converters

C# Class to SQL Table Generator

Generate CREATE TABLE statements from C# classes for SQL Server, MySQL, and PostgreSQL.

T-SQL, MySQL, PostgreSQL PK inference Nullable mapping

How the C# Class to SQL Table Generator Works

The ByteKiln C# to SQL generator maps each property in your class to a SQL column with the appropriate data type for your chosen dialect. The CREATE TABLE statement is generated entirely in your browser.

How .NET types map to SQL

string becomes NVARCHAR(255) for SQL Server, VARCHAR(255) for MySQL, or TEXT for PostgreSQL. int becomes INT, long becomes BIGINT, bool becomes BIT or BOOLEAN, and DateTime becomes DATETIME or TIMESTAMP.

Primary key inference

Properties named Id or <ClassName>Id are automatically set as the primary key. Integer PKs receive IDENTITY (SQL Server), AUTO_INCREMENT (MySQL), or SERIAL (PostgreSQL) semantics depending on the selected dialect.

Nullable columns

Nullable value types like int? and DateTime? generate columns with NULL constraints. Non-nullable value types generate NOT NULL columns. Reference types like string are nullable by default.

FAQ

Short answers for the things developers usually ask before trusting a tool.

Which SQL dialects does the ByteKiln C# to SQL generator support?

The generator supports SQL Server (T-SQL), MySQL, and PostgreSQL. Each dialect uses the correct data types — for example, NVARCHAR for SQL Server, VARCHAR for MySQL, and TEXT for PostgreSQL string columns.

How are primary keys inferred from C# classes?

Properties named Id or <ClassName>Id are treated as primary keys. Integer keys get IDENTITY or AUTO_INCREMENT semantics depending on the dialect. You can rename or annotate the property to change this behavior.

Does it support nullable properties?

Yes. Nullable types like int? and string? generate columns with NULL constraints, while non-nullable value types generate NOT NULL columns.

Is my C# code uploaded to a server?

No. The ByteKiln C# to SQL tool runs entirely in your browser. Your class definitions are never transmitted, stored, or logged anywhere.

Does it support Entity Framework data annotations?

Not fully. The generator targets practical POCO-to-DDL scaffolding. EF-specific attributes like [Column], [MaxLength], and [ForeignKey] are not yet parsed, but standard property types and naming conventions are handled well.

Related tools

Useful follow-ups when one conversion usually turns into three more.