public void Migrate() { var commentGroups = SourceDbContext.CommentGroups.ToList(); foreach (var commentGroup in commentGroups) { var newEntity = new CommentGroup() { Id = _commentGroupKeyMapper.MapKey(commentGroup.Id), PostDate = commentGroup.PostDate }; TargetDbContext.CommentGroups.Add(newEntity); } TargetDbContext.SaveChanges(); }
public void Migrate() { var comments = SourceDbContext.Comments.ToList(); foreach (var comment in comments) { var newEntity = new Comment() { Id = _commentKeyMapper.MapKey(comment.Id), PostDate = comment.PostDate, Content = comment.Message, GroupId = _commentGroupKeyMapper.MapKey(comment.GroupId), PosterId = _userKeyMapper.MapKey(comment.PosterId) }; TargetDbContext.Comments.Add(newEntity); } TargetDbContext.SaveChanges(); }
public void Migrate() { var events = SourceDbContext.Events.ToList(); foreach (var oldEvent in events) { var newEntity = new Event() { Id = _eventKeyMapper.MapKey(oldEvent.Id), InviteTime = oldEvent.InviteTime, StartTime = oldEvent.StartTime, EndTime = oldEvent.EndTime, Name = oldEvent.Name, Description = oldEvent.Description, State = StringToEventState.Convert(oldEvent.State), CommentGroupId = _commentGroupKeyMapper.MapKey(oldEvent.CommentGroupId), OrganiserId = _userKeyMapper.MapKey(oldEvent.OrganiserId) }; TargetDbContext.Events.Add(newEntity); } TargetDbContext.SaveChanges(); }