Schema specified is not valid. The relationship was not loaded because the type is not available

Viewed 122

I have 2 tables as below

Test1 - which has PK as Id

Test2 - which has FK references of Test1 Table PK

Test3 - which has FK references of Test1 Table PK

While i am executing linq query to fetch details from Test1 it throws below issue.

Schema specified is not valid. Errors: The relationship 'Model.FK__Test2__Id__18EBB532' was not loaded because the type 'Model.Test1' is not available. The following information may be useful in resolving the previous error: The required property 'Test3' does not exist on the type 'Test1'.

i have ensured mapping and everything is proper in model as below

public partial class Test1
{    
    public Test1()
    {
        this.Test2 = new HashSet<Test2>();
    }

    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<Test2> Test2 { get; set; }
}

public partial class Test2
{
    public int Id { get; set; }
    public string Name { get; set; }

    public virtual Test1 Test1 { get; set; }
}

But still i can face the same issue. i have tried to refresh the entity. that also doesn't fix this issue.

I have tried to add [Key] and [ForeignKey("xxx")] attributes also which doesn't make it work.

Please provide solution to fix this.

Thanks in advance.

0 Answers
Related