注:本文系作者原创,但可随意转载。

  现在呆的公司使用的数据库几乎都是MySQL。编程方式DatabaseFirst。即先写数据库设计,表设计按照规范好的文档写进EXCEL里,然后用公司的宏,生成建表脚本和实体类文件。

  之前就见识过T4模板生成SQL实体类文件,但还没自己实践过,这次正好实现一下生成MySQL的实体类。

 

目标类文件结构大致如下:

 1 //-----------------------------------------------------------------------
 2 // <copyright file=" UserProfile2.cs" company="xxx Enterprises">
 3 // * Copyright (C) 2015 xxx Enterprises All Rights Reserved
 4 // * version : 4.0.30319.18444
 5 // * author  : auto generated by T4
 6 // * FileName: UserProfile2.cs
 7 // * history : Created by T4 11/24/2015 18:05:30 
 8 // </copyright>
 9 //-----------------------------------------------------------------------
10 using System;
11 
12 namespace Console4Test
13 {
14     /// <summary>
15     /// UserProfile2 Entity Model
16     /// </summary>    
17     [Serializable]
18     public class UserProfile2
19     {
20         /// <summary>
21         /// 主键ID
22         /// </summary>
23         public string ID { get; set; }
24     
25         /// <summary>
26         /// 姓名
27         /// </summary>
28         public string Name { get; set; }
29     
30         /// <summary>
31         /// 年龄
32         /// </summary>
33         public int Age { get; set; }
34     
35         /// <summary>
36         /// 性别
37         /// </summary>
38         public int Gender { get; set; }
39     }
40 }
UserProfile2

相关文章:

  • 2021-08-06
  • 2021-05-30
  • 2018-11-13
  • 2021-06-05
  • 2021-10-14
  • 2020-01-19
  • 2020-12-31
猜你喜欢
  • 2021-09-11
  • 2019-12-09
  • 2021-09-05
  • 2022-01-10
  • 2021-10-17
  • 2021-10-11
  • 2022-01-16
相关资源
相似解决方案