protected override void PerformAddOrUpdate(TypedEntity entity) { ValidateEntityForMembership(entity); //loop through the providers foreach (var m in MembershipProviders) { if (!entity.Id.IsNullValueOrEmpty()) { var found = m.GetUser(entity.Id.Value.Value, false); if (found != null) { //its an existing uer FrameworkContext.TypeMappers.Map(entity, found); m.UpdateUser(found); continue; } } //new user MembershipCreateStatus status; var member = m.CreateUser( entity.Attribute <string>("username".ToRebelAlias()), entity.Attribute <string>("password".ToRebelAlias()), entity.Attribute <string>("email".ToRebelAlias()), entity.Attribute <string>("passwordQuestion".ToRebelAlias()), entity.Attribute <string>("passwordAnswer".ToRebelAlias()), entity.Attribute <bool>("isApproved".ToRebelAlias()), entity.Id.Value.Value, out status); if (status != MembershipCreateStatus.Success) { throw new InvalidOperationException("Could not create a new membership user. Failed with status: " + status); } //re-map it FrameworkContext.TypeMappers.Map(member, (TypedEntity)entity); } }