In my API project, I have
public class Team
{
[Key]
public long Id { set; get; }
[Required]
public TeamSettings TeamSettings { get; set; }
}
public class TeamSettings
{
[Key]
[Required]
[Column("TeamSettingsId")]
public long Id { set; get; }
[Required]
[ForeignKey("TeamId")]
public long TeamId { get; set; }
[Required]
public Team Team { set; get; }
}
When I use
var team = await TeamRepo.GetAsync(t => t.Id == teamId, includes);
I can see on my SQL Server Profiler a left join rather than an inner join.
I tried removing the annotations and going for fluent like this:
modelBuilder.Entity<Team>()
.HasOne(t => t.TeamSettings)
.WithOne(ts => ts.Team)
.HasForeignKey<TeamSettings>(ts => ts.TeamId);
But still, all I get is a left join.
Since TeamSettings is created always for any team and is not nullable, shouldn't it be using inner join?