Duplicate ForeignKey when using inheritance

Viewed 1675

I have created these classes in order to generate the database model via EntityFramework 6 code-first approach:

public class Vehicle 
{
    public long Id { get; set; }

    public long ResponsiblePersonId { get; set; }
}

public class Car: Vehicle {

    public int HorsePower { get; set; }

}

public class Bike: Vehicle {

    public int FrameSize { get; set; }

}

public class Organisation
{
    public Organisation()
    {
        Cars = new List<Car>();
        Bikes = new List<Bikes>();
    }

    public long Id { get; set; }


    public List<Car> Cars { get; set; }

    public List<Bike> Bikes { get; set; }
}

So far this seemed right for me. But unfortunately, the resulting table looks like this:

Id | ResponsiblePersonId | HorsePower | FrameSize | Discriminator | Organisation_Id | Organisation_Id1

Why is the Organisation ForeignKey being generated twice? I expected this table to only have one Organisation_Id column.

Thanks

1 Answers
Related