Код: Выделить всё
modelBuilder.Entity()
.Property(a => a.Name)
.IsRequired();
modelBuilder.Entity()
.Property(a => a.Type)
.IsRequired();
modelBuilder.Entity()
.Property(a => a.Title)
.IsRequired();
modelBuilder.Entity().HasOne(x => x.Artist);
modelBuilder.Entity().HasOne(x => x.AlbumType);
modelBuilder.Entity().HasMany(x => x.Songs);
modelBuilder.Entity()
.Property(a => a.Title)
.IsRequired();
modelBuilder.Entity().HasOne(x => x.Artist);
Код: Выделить всё
var album = await unitOfWork.AlbumRepository.GetByIDAsync(id);
try
{
_context.Entry(album).Reference(a => a.Artist).Load();
_context.Entry(album).Reference(a => a.AlbumType).Load();
_context.Entry(album).Collection(a => a.Songs).Load();
}
catch (Exception ex)
{
throw ex;
}
return album;
Код: Выделить всё
public virtual async Task GetByIDAsync(object id)
{
return await dbSet.FindAsync(id);
}
Но я не могу получить информацию об исполнителе этой песни. Кто-нибудь может мне помочь?
Подробнее здесь: https://stackoverflow.com/questions/790 ... sing-dbset