new models
This commit is contained in:
@@ -19,6 +19,15 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public ICollection<GenreMedia> GenreMedia { get; set; }
|
||||
public ICollection<Media.Media> Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Genre>.Build(EntityTypeBuilder<Genre> builder)
|
||||
@@ -35,6 +44,11 @@ namespace WatchIt.Database.Model.Genre
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<GenreMedia>();
|
||||
}
|
||||
|
||||
static IEnumerable<Genre> IEntity<Genre>.InsertData() => new List<Genre>
|
||||
|
||||
52
WatchIt.Database/WatchIt.Database.Model/Genre/GenreMedia.cs
Normal file
52
WatchIt.Database/WatchIt.Database.Model/Genre/GenreMedia.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Genre
|
||||
{
|
||||
public class GenreMedia : IEntity<GenreMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long MediaId { get; set; }
|
||||
public short GenreId { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
public Genre Genre { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<GenreMedia>.Build(EntityTypeBuilder<GenreMedia> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.GenreMedia)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user