EntityFramework Fluent API create Relationships without Navigation Properties

Viewed 1353

Is there a way to create a relationship between two classes using only Ids?
In this example I'm trying to create a One-to-Many relationship between Companyand Employee (One Company has many Employee)

Here's my code:

public class Company
{
    public Guid Id { get; set; }
    public string CompanyName { get; set; }

}

and

public class Employee
{
    public Guid Id { get; set; }
    public string Name { get; set; }

    public Guid CompanyId { get; set; }
}

Using Fluent API I'm able to create the relationship, as long as I create a Navigation Property. I'm looking for a way to relate those two classes by Company.Id and Employee.CompanyId without any navigation properties.

Thanks in advance.

1 Answers
Related