1 模型设计
1.1 设计窗口截图
2 代码
CREATE TABLE `mydb`.`sp_user` ( `user_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', `username` varchar(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '登录名', `qq_open_id` char(32) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT 'qq官方唯一编号信息', `password` char(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '登录密码', `user_email` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '邮箱', `user_email_code` char(13) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '新用户注册邮件激活唯一校验码', `is_active` enum('是','否') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '否' COMMENT '新用户是否已经通过邮箱激活帐号', `user_sex` enum('保密','女','男') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '男' COMMENT '性别', `user_qq` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'qq', `user_tel` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '手机', `user_xueli` enum('博士','硕士','本科','专科','高中','初中','小学') CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '本科' COMMENT '学历', `user_hobby` varchar(32) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '爱好', `user_introduce` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '简介', `create_time` int(11) NOT NULL COMMENT '创建时间', `update_time` int(11) NOT NULL COMMENT '修改时间', PRIMARY KEY (`user_id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '会员表' ROW_FORMAT = Dynamic;
2.1 实体代码
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Text; namespace Xwy.Domain.Entities { public class AppUser { /// <summary> /// 编号,主键自增 /// </summary> public int Id { get; set; } /// <summary> /// 用户名,必填 /// </summary> [Required] [StringLength(128)] public string UserName { get; set; } /// <summary> /// 密码,必填 /// </summary> [Required] [StringLength(128)] //最好能固定为64位的md5格式 public string Password { get; set; } /// <summary> /// qq官方唯一编号信息 /// </summary> [StringLength(128)] //最好能固定为32位 public string QQOpenId { get; set; } /// <summary> /// 邮箱,必填 /// </summary> [Required] [StringLength(64)] public string UserEmail { get; set; } /// <summary> /// 新用户注册邮件激活唯一校验码,最好固定为13位 /// </summary> [StringLength(13)] public string UserEmailCode { get; set; } /// <summary> /// 新用户是否已经通过邮箱激活帐号,默认值为0=否,1=是 /// </summary> public byte IsActive { get; set; } /// <summary> /// 性别,默认0,0=保密,1=男,2=女 /// </summary> public byte UserSex { get; set; } /// <summary> /// qq /// </summary> [Required] [StringLength(32)] public string UserQQ { get; set; } /// <summary> /// 手机 /// </summary> [Required] [StringLength(32)] public string UserTel{ get; set; } /// <summary> /// 学历:'博士','硕士','本科','专科','高中','初中','小学' /// </summary> [Required] [StringLength(32)] public byte UserXueli { get; set; } /// <summary> /// 爱好 /// </summary> [Required] [StringLength(32)] public string UserHobby { get; set; } /// <summary> /// 简介 /// </summary> public string UserIntroduce { get; set; } /// <summary> /// 创建时间 /// </summary> public DateTimeOffset CreateTime{ get; set; } /// <summary> /// 修改时间 /// </summary> public DateTimeOffset UpdateTime { get; set; } } }