🧩 SQL 建表语句转 C# 实体类SQL CREATE TABLE to C# Class
把 MySQL、SQL Server、PostgreSQL、Oracle 的 CREATE TABLE 语句转换成 C# 实体类:自动映射字段类型、可空类型、注释,可选 Entity Framework 数据注解和 record 写法。Turn MySQL, SQL Server, PostgreSQL or Oracle CREATE TABLE statements into C# entity classes with mapped types, nullable types and comments, plus optional Entity Framework data annotations or records.
使用说明与常见问题How-to & FAQ
「SQL 建表语句转 C# 实体类」是什么?What is the SQL CREATE TABLE to C# Class tool?
把 MySQL、SQL Server、PostgreSQL、Oracle 的 CREATE TABLE 语句转换成 C# 实体类:自动映射字段类型、可空类型、注释,可选 Entity Framework 数据注解和 record 写法。Turn MySQL, SQL Server, PostgreSQL or Oracle CREATE TABLE statements into C# entity classes with mapped types, nullable types and comments, plus optional Entity Framework data annotations or records.
如何使用「SQL 建表语句转 C# 实体类」?How do I use the SQL CREATE TABLE to C# Class?
粘贴一条或多条 CREATE TABLE 语句(可直接用 SHOW CREATE TABLE 或数据库工具导出的 DDL),设置命名空间和选项,右侧即生成对应的 C# 类。字段注释(COMMENT)会变成 XML 文档注释。Paste one or more CREATE TABLE statements (e.g. from SHOW CREATE TABLE or a DDL export), set the namespace and options, and the C# classes appear below. Column COMMENTs become XML doc comments.
数据库类型是怎么对应到 C# 的?How are SQL types mapped to C#?
int→int,bigint→long,tinyint(1)/bit→bool,decimal/numeric/money→decimal,float/double→double,real→float,char/varchar/text→string,date/datetime/timestamp→DateTime,datetimeoffset/timestamptz→DateTimeOffset,uuid/uniqueidentifier→Guid,blob/varbinary/bytea→byte[];unsigned 会用对应的无符号类型。int→int, bigint→long, tinyint(1)/bit→bool, decimal/numeric/money→decimal, float/double→double, real→float, char/varchar/text→string, date/datetime/timestamp→DateTime, datetimeoffset/timestamptz→DateTimeOffset, uuid/uniqueidentifier→Guid, blob/varbinary/bytea→byte[]; unsigned columns use unsigned types.
什么时候生成 int? 这样的可空类型?When are nullable types like int? used?
没有 NOT NULL(也不是主键)的列会生成可空类型。值类型总是加 ?;string 等引用类型只有勾选「可空引用类型」时才加 ?。Columns without NOT NULL (and not primary keys) become nullable. Value types always get ?; reference types like string get ? only when "Nullable reference types" is checked.
「SQL 建表语句转 C# 实体类」免费吗?数据会上传吗?Is the SQL CREATE TABLE to C# Class free? Is my data uploaded?
「SQL 建表语句转 C# 实体类」完全免费,无需注册或安装,手机和电脑都能用;所有处理都在你的浏览器本地完成,输入的内容和文件不会上传到服务器。The SQL CREATE TABLE to C# Class is completely free with no sign-up or install and works on phones and desktops; everything runs locally in your browser and nothing you enter is uploaded.