EF Unable to determine the relationship represented by navigation property

asp.net-core c# entity-framework-core

Question

I get an error from EntityFramework when I attempt to execute this code, stating that it was unable to identify the connection represented by navigation property "Workflow1.Step1" of type "Step1". Any suggestions on how to fix this? I tried blindly configuring it in OnModelCreating, but it didn't work.

If I remove DbQuery, the code runs well, but I need it to be there so that I may query on the data without executing an Include from a workflow and yet guarantee that no changes are performed within the step.

public class Workflow1
{
        public Guid Id { get; private set; }

        public Guid Step1Id {get; private set;}
        public Step1 Step1 {get; private set;}

        public Guid Step2Id {get; private set;}
        public Step2 Step2 {get; private set;}

        public Guid Step3Id {get; private set;}
        public Step3 Step3 {get; private set;}
}

public class Workflow2
{
        public Guid Step2Id {get; private set;}
        public Step2 Step2 {get; private set;}

        public Guid Step4Id {get; private set;}
        public Step5 Step4 {get; private set;}
}

public class Step1 
{
    public Guid Id { get; private set; }
}

public class AppDbContext : DbContext
{
    public AppDbContext(DbContextOptions<AppDbContext> options) :base(options)
    {}

    public DbSet<Workflow1> Workflow1 { get; set; }
    public DbSet<Workflow2> Workflow2 { get; set; }

    public DbQuery<Step1> Step1 { get; set; }
    public DbQuery<Step3> Step2 { get; set; }
    public DbQuery<Step3> Step3 { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
    }
}
1
0
12/10/2018 5:28:23 PM

Accepted Answer

ZZZ_tmp
1
12/10/2018 5:38:32 PM






Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow