I'm trying to learn one to many relations with EF Core.
In summary: I have two tables; Artists and Songs.
But when I try to reach songs which belongs that artist I am getting error.
Why I'm getting null reference error?
I'm trying to learn one to many relations with EF Core.
In summary: I have two tables; Artists and Songs.
But when I try to reach songs which belongs that artist I am getting error.
Why I'm getting null reference error?
You have to include the related entity you want in the list manually, include Songs like the following way:
var theArtist = DB.Artists.Include("Songs").FirstOrDefault(a => a.ID==1);