/// <summary>
        /// 初始化数据库的时候更改表结构,创建唯一键
        /// </summary>
        /// <returns></returns>
        public async Task InitTableSchema()
        {
            // 数据库表名和字段名不能写死, 因为可能会在后面重构阶段更改
            dbContext.Database.ExecuteSqlCommand(string.Format("alter table {0} add constraint unique_RecruitUser_nickname unique ({1});", nameof(recruit_user), nameof(recruit_user.nickname)));
            dbContext.Database.ExecuteSqlCommand(string.Format("alter table {0} add constraint unique_RecruitUser_phone unique ({1});", nameof(recruit_user), nameof(recruit_user.phone)));
            dbContext.Database.ExecuteSqlCommand(string.Format("alter table {0} add constraint unique_RecruitUser_email unique ({1});", nameof(recruit_user), nameof(recruit_user.email)));

            await dbContext.SaveChangesAsync();
        }
示例#2
0
 public Task SaveChanges()
 => _context.SaveChangesAsync();
示例#3
0
 public async Task SaveChanges()
 => await _context.SaveChangesAsync();