How to force outer join with .Include query Entity Framework 6

Viewed 2310

My data model is below. UserPhone is required but navigation property is optional as long as User's table could be empty:

public class Request
{
    [Key]
    public int Id {get;set;}
    [Required]
    public string UserPhone {get;set;}
    [ForeignKey("UserPhone")]
    public virtual User User {get;set;}
}

public class User
{
    [Key]
    public string UserPhone {get;set;}
}

The Users table is populated after a request is entered into the system. And somewhere between the request is entered and the user is not populated I'm trying to fetch all the requests with a user, if exists (outer join).

db.Requests.Include(r=>r.User).FirstOrDefault();

Which gives me zero results because EF did inner join (my UserPhone field is defined and a foreign key and it is required for the Requests table).

How can I properly define the mapping to be able to use include mapping? I need the include because my case touched several more tables I would like to do all with manual joins

1 Answers
Related