WCF.多条数据插入的事务 RRS feed

  • 问题

  • 创建用户时,要操作多个表(insert)。我创建一个事务,报下面的错误信息.

    The transaction manager has disabled its support for remote/network transactions. (Exception from HRESULT: 0x8004D024)


    [OperationBehavior(TransactionScopeRequired = true)]
        public int CreateUser(CreateUserData createData)
            // Create a new family group and get the ID
            var familyGroupId = createData.FamilyGroupId ?? CreateFamilyGroup();
            // Create the APUser and get the Id 
            var apUserId = CreateAPUser(createData.UserId, familyGroupId);
            // Create the institution user and get the Id
            var institutionUserId = CreateInsUser(apUserId, createData.AlternateId, createData.InstitutionId);
            // Create the investigator group user and return the Id
            return AddUserToGroup(createData.InvestigatorGroupId, institutionUserId);

    public int CreateFamilyGroup(string familyGroupName)
            var familyRepo = _FamilyRepo ?? new FamilyGroupRepository();
            var familyGroup = new FamilyGroup() {CreationDate = DateTime.Now};
            return familyRepo.AddFamilyGroup(familyGroup);

    public int AddFamilyGroup(FamilyGroup familyGroup)
                using (var context = new GameDbContext())
                    var newGroup = context.FamilyGroups.Add(familyGroup);
                    return newGroup.FamilyGroupId;
    2016年2月4日 13:59