Files
WatchIt/WatchIt.Database/WatchIt.Database.Model/Media/MediaGenre.cs

53 lines
1.2 KiB
C#
Raw Normal View History

2024-03-18 00:14:08 +01:00
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
2024-03-19 17:25:13 +01:00
using WatchIt.Database.Model.Common;
2024-03-18 00:14:08 +01:00
2024-03-19 17:25:13 +01:00
namespace WatchIt.Database.Model.Media
2024-03-18 00:14:08 +01:00
{
2024-03-19 17:25:13 +01:00
public class MediaGenre : IEntity<MediaGenre>
2024-03-18 00:14:08 +01:00
{
#region PROPERTIES
public long MediaId { get; set; }
public short GenreId { get; set; }
#endregion
#region NAVIGATION
2024-03-19 17:25:13 +01:00
public Media Media { get; set; }
2024-03-18 00:14:08 +01:00
public Genre Genre { get; set; }
#endregion
#region PUBLIC METHODS
2024-03-19 17:25:13 +01:00
static void IEntity<MediaGenre>.Build(EntityTypeBuilder<MediaGenre> builder)
2024-03-18 00:14:08 +01:00
{
builder.HasOne(x => x.Media)
2024-03-19 17:25:13 +01:00
.WithMany(x => x.MediaGenres)
2024-03-18 00:14:08 +01:00
.HasForeignKey(x => x.MediaId)
.IsRequired();
builder.Property(x => x.MediaId)
.IsRequired();
builder.HasOne(x => x.Genre)
2024-03-19 17:25:13 +01:00
.WithMany(x => x.MediaGenres)
2024-03-18 00:14:08 +01:00
.HasForeignKey(x => x.GenreId)
.IsRequired();
builder.Property(x => x.GenreId)
.IsRequired();
}
#endregion
}
}