❔ Ef core-Odd Behavior

So straight into it,
The mapping:
builder.Entity<LessonPhase>(b =>
{
b.ToTable(lingumindConsts.DbTablePrefix + "Phases", lingumindConsts.DbSchema);

b.HasOne(x => x.BotInitialInteraction).WithOne(x => x.LessonPhaseForInitial)
.HasForeignKey<BotInteraction>(x => x.LessonPhaseForInitialId);
b.HasOne(x => x.BotFinalInteractionOnSuccess).WithOne(x => x.LessonPhaseForOnSuccess)
.HasForeignKey<BotInteraction>(x => x.LessonPhaseForOnSuccessId);
b.HasOne(x => x.BotFinalInteractionOnFailure).WithOne(x => x.LessonPhaseForOnFailure)
.HasForeignKey<BotInteraction>(x => x.LessonPhaseForOnFailureId);
b.HasMany(x => x.UserInteractions).WithOne(x => x.LessonPhase).HasForeignKey(x => x.LessonPhaseId);

});

The Class:
public class LessonPhase : AuditedEntity<Guid>, ISoftDelete
{

 }
    public BotInteraction BotInitialInteraction { get; set; }
    public BotInteraction? BotFinalInteractionOnSuccess { get; set; }
    public BotInteraction? BotFinalInteractionOnFailure { get; set; }
    public string? UserExpectedAnswer { get; set; } 
    public ICollection<UserInteraction> UserInteractions { get; set; }

    public LessonPhase(Guid id) : base(id)
    {
        UserInteractions = new Collection<UserInteraction>();
    }}

The Code:
            _currentLesson = await HandlePhaseAudioFileStorage(_currentLesson);
            if (AzureBlobStorageManager.StoreEnabled) { 
             var newLesson=await _lessonRepository.InsertAsync(_currentLesson, true);

            }

Basically After saving to the DB, the last phase, lets say number 6, The InitialBotInteraction string value becomes the same as the BotFinalInteractionOnSuccess string,
Only happens on the last phase all the others are fine, so the heck is going on?
Was this page helpful?