根据MySQL表生成C#实体模型
1 USE INFORMATION_SCHEMA; 2 SELECT 3 CONCAT( 4 '/// <summary>\r\n/// ', 5 COLUMN_COMMENT, 6 '\r\n/// </summary>\r\n[DataMember]\r\npublic ', 7 CASE 8 DATA_TYPE 9 WHEN 'bigint' THEN 10 IF(IS_NULLABLE='YES','int?','int') 11 WHEN 'tinyint' THEN 12 IF(IS_NULLABLE='YES','int?','int') 13 WHEN 'varchar' THEN 14 'string' 15 WHEN 'varbinary' THEN 16 'string' 17 WHEN 'text' THEN 18 'string' 19 WHEN 'char' THEN 20 'string' 21 WHEN 'datetime' THEN 22 IF(IS_NULLABLE='YES','DateTime?','DateTime') 23 WHEN 'bit' THEN 24 IF(IS_NULLABLE='YES','bool?','bool') 25 WHEN 'decimal' THEN 26 IF(IS_NULLABLE='YES','decimal?','decimal') 27 ELSE DATA_TYPE 28 END, 29 ' ', 30 COLUMN_NAME, 31 ' {get;set;}\r\n' 32 ) 33 FROM 34 COLUMNS 35 WHERE 36 TABLE_SCHEMA = 'DBName' 37 AND TABLE_NAME = 'TableName';