TableName 要生成的表名
DBName 表所在库的名称 //加这个的原因是怕不同库中有相同的表名
SET @DBName='BaseDatabase'; SET @TableName='UserInfo'; SELECT CONCAT( '/// <summary>\r\n/// ', COLUMN_COMMENT, '\r\n/// </summary>\r\npublic ', CASE DATA_TYPE WHEN 'bigint' THEN 'int' WHEN 'tinyint' THEN 'int' WHEN 'varchar' THEN 'string' WHEN 'varbinary' THEN 'string' WHEN 'text' THEN 'string' WHEN 'char' THEN 'string' WHEN 'datetime' THEN 'DateTime' WHEN 'bit' THEN 'bool' WHEN 'decimal' THEN 'decimal' ELSE DATA_TYPE END, ' ', COLUMN_NAME, ' {get;set;}' ) AS Remark FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = @DBName AND TABLE_NAME = @TableName;