Entity Framework Core null object. I have a one-to-one entity relationship.
public class Player
{
public int Id { get; set; }
public int? RatingId { get; set; }
public Rating Rating { get; set; }
}
public class Rating
{
public double Mean { get; set; }
}
In my player controller I return
var player = await _context.Player.FindAsync(id);
However this is my json
{
"id": 3010,
"ratingId": 2009,
"rating": null,
"displayName": "Conor",
"partialPlayPercentage": 0.5,
"partialUpdatePercentage": 1
}
Is rating supposed to be null here?
FTI When I call
var rating = await _context.Rating.FindAsync(2009);
I get the correct rating