❔ Ef core creating shadow foreign key, why?

Got this error:
The foreign key property 'LessonPhase.LessonId1' was created in shadow state because a conflicting property with the simple name 'LessonId' exists in the entity type, but is either not mapped, is already used for another relationship, or is incompatible with the associated primary key type

The classes:
public class LessonPhase : Entity<Guid>, ISoftDelete
{
    public required int PhaseNumber { get; init; }
    public int NumberOfExplanationRequestsMade { get; set; }
    public Lesson Lesson { get; init; }
    public Guid LessonId { get; init; }
    public bool IsDeleted { get; set; }

public class Lesson : FullAuditedAggregateRootWithUser<Guid, IdentityUser>
{
    public required string LessonSrcLanguage { get; init; }
    public required string LessonDstLanguage { get; init; }
    public int LessonNumber { get; set; }
    public int LessonDifficulty { get; init; }
    public required LessonState LessonState { get; set; }
    public ICollection<LessonPhase> Phases { get; set; }
    public LessonPhase CurrentPhase { get; set; }

    public Lesson()
    {
        Phases = new Collection<LessonPhase>();
    }
}

Mapping:
  builder.Entity<Lesson>(b =>
        {
            b.ToTable(lingumindConsts.DbTablePrefix + "Lessons", lingumindConsts.DbSchema);
            b.ConfigureByConvention(); //auto configure for the base class props
        });

        builder.Entity<LessonPhase>(b =>
        {
            b.ToTable(lingumindConsts.DbTablePrefix + "Phases", lingumindConsts.DbSchema);
            b.HasOne(x => x.Lesson).WithMany(x => x.Phases).HasForeignKey(x => x.LessonId);


Any idea? Cant seem to resolve this
Was this page helpful?