0

I have a class TrainingSpecialty which is mapped as follows:

public TrainingSpecialityMap()
{
    Table("TrainingSpecialty");
    Id(o => o.Id).GeneratedBy.Native();
    DiscriminateSubClassesOnColumn(CandidateTrainingDatabase.TrainingSpecialtyTable.IsCombinedColumn)
        .Formula(
            string.Format("case when {0} is null then 0 else {0} end", CandidateTrainingDatabase.TrainingSpecialtyTable.IsCombinedColumn));
            Map(o => o.Code);
            Map(o => o.Name).Not.Nullable();
            Map(o => o.TrainingProgramType, "ProgramType").Not.Nullable();
            HasMany(o => o.Forms)
                .Not.KeyNullable()
                .KeyColumn("TrainingSpecialtyID").Cascade
                .SaveUpdate();
            Map(o => o.ProcedureTitle).Nullable();
            HasMany(o => o.Procedures);
}

I'm attempting to create a new Form, add it to the TrainingSpecialty.Forms list and then update the TrainingSpecialty. The purpose of this is to add the new form. (Note that Form does NOT have a navigation property back to the TrainingSpecialty. Without changing the Form class, there is no simple way to just add the form with a reference to the TrainingSpecialty, which is why I'm updating the TrainingSpecialty.)

The first error I'm getting upon Updating the TrainingSpecialty is Error dehydrating property value for Domain.EvaluationForm.Domain.TrainingSpecialty.FormsBackref.

The inner exception is Invalid index 3 for this SqlParameterCollection with Count=3.

There should always be one previously existing form and I'm now attempting to add a second. I've looked for fields that are duplicately mapped (as per others who have had this issue).

How is this mapping off?

Steve Wash
  • 986
  • 4
  • 23
  • 50

1 Answers1

0

It was a duplicate mapping, just like so many others like this. In this case the Form mapping someone had added a reference back to the Training Specialty.

Steve Wash
  • 986
  • 4
  • 23
  • 50