new tables
This commit is contained in:
@@ -9,7 +9,9 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
@@ -21,6 +23,7 @@ namespace WatchIt.Database.Model.Account
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Description { get; set; }
|
||||
public short GenderId { get; set; }
|
||||
public Guid? ProfilePictureId { get; set; }
|
||||
public Guid? BackgroundPictureId { get; set; }
|
||||
public byte[] Password { get; set; }
|
||||
@@ -36,9 +39,16 @@ namespace WatchIt.Database.Model.Account
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Gender Gender { get; set; }
|
||||
public AccountProfilePicture? ProfilePicture { get; set; }
|
||||
public MediaPhotoImage? BackgroundPicture { get; set; }
|
||||
|
||||
public IEnumerable<RatingMedia> RatingMedia { get; set; }
|
||||
public IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; }
|
||||
public IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -64,6 +74,13 @@ namespace WatchIt.Database.Model.Account
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenderId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.ProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Account>(e => e.ProfilePictureId);
|
||||
|
||||
41
WatchIt.Database/WatchIt.Database.Model/Common/Gender.cs
Normal file
41
WatchIt.Database/WatchIt.Database.Model/Common/Gender.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.DataSeeding;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Common
|
||||
{
|
||||
public class Gender : IEntity<Gender>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public short Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<Gender>.Build(EntityTypeBuilder<Gender> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
static IEnumerable<Gender> IEntity<Gender>.InsertData() => DataReader.Read<Gender>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
@@ -42,6 +44,10 @@ namespace WatchIt.Database.Model.Media
|
||||
|
||||
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
|
||||
public IEnumerable<RatingMedia> RatingMedia { get; set; }
|
||||
|
||||
public IEnumerable<ViewCountMedia> ViewCountsMedia { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace WatchIt.Database.Model.Media
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesSeason MediaSeriesSeason { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesEpisode> RatingMediaSeriesEpisode { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Media
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace WatchIt.Database.Model.Media
|
||||
|
||||
public MediaSeries MediaSeries { get; set; }
|
||||
public IEnumerable<MediaSeriesEpisode> MediaSeriesEpisodes { get; set; }
|
||||
public IEnumerable<RatingMediaSeriesSeason> RatingMediaSeriesSeason { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Account;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
@@ -18,6 +20,7 @@ namespace WatchIt.Database.Model.Person
|
||||
public string? Description { get; set; }
|
||||
public DateOnly? BirthDate { get; set; }
|
||||
public DateOnly? DeathDate { get; set; }
|
||||
public short GenderId { get; set; }
|
||||
public Guid? PersonPhotoId { get; set; }
|
||||
|
||||
#endregion
|
||||
@@ -26,9 +29,11 @@ namespace WatchIt.Database.Model.Person
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Gender Gender { get; set; }
|
||||
public PersonPhotoImage? PersonPhoto { get; set; }
|
||||
public IEnumerable<PersonActorRole> PersonActorRoles { get; set; }
|
||||
public IEnumerable<PersonCreatorRole> PersonCreatorRoles { get; set; }
|
||||
public IEnumerable<ViewCountPerson> ViewCountsPerson { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -58,6 +63,13 @@ namespace WatchIt.Database.Model.Person
|
||||
|
||||
builder.Property(x => x.DeathDate);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenderId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonPhoto)
|
||||
.WithOne(x => x.Person)
|
||||
.HasForeignKey<Person>(e => e.PersonPhotoId);
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
@@ -28,6 +29,8 @@ namespace WatchIt.Database.Model.Person
|
||||
public Media.Media Media { get; set; }
|
||||
public PersonActorRoleType PersonActorRoleType { get; set; }
|
||||
|
||||
public IEnumerable<RatingPersonActorRole> RatingPersonActorRole { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Person
|
||||
{
|
||||
@@ -25,6 +26,7 @@ namespace WatchIt.Database.Model.Person
|
||||
public Person Person { get; set; }
|
||||
public Media.Media Media { get; set; }
|
||||
public PersonCreatorRoleType PersonCreatorRoleType { get; set; }
|
||||
public IEnumerable<RatingPersonCreatorRole> RatingPersonCreatorRole { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingMedia : IEntity<RatingMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMedia>.Build(EntityTypeBuilder<RatingMedia> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMedia)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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.Rating
|
||||
{
|
||||
public class RatingMediaSeriesEpisode : IEntity<RatingMediaSeriesEpisode>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid MediaSeriesEpisodeId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesEpisode MediaSeriesEpisode { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMediaSeriesEpisode>.Build(EntityTypeBuilder<RatingMediaSeriesEpisode> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesEpisode)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesEpisodeId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesEpisode)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingMediaSeriesSeason : IEntity<RatingMediaSeriesSeason>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid MediaSeriesSeasonId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public MediaSeriesSeason MediaSeriesSeason { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingMediaSeriesSeason>.Build(EntityTypeBuilder<RatingMediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeriesSeason)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingMediaSeriesSeason)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingPersonActorRole : IEntity<RatingPersonActorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid PersonActorRoleId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public PersonActorRole PersonActorRole { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingPersonActorRole>.Build(EntityTypeBuilder<RatingPersonActorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonActorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRole)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonActorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Rating
|
||||
{
|
||||
public class RatingPersonCreatorRole : IEntity<RatingPersonCreatorRole>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public Guid PersonCreatorRoleId { get; set; }
|
||||
public long AccountId { get; set; }
|
||||
public short Rating { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public PersonCreatorRole PersonCreatorRole { get; set; }
|
||||
public Account.Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<RatingPersonCreatorRole>.Build(EntityTypeBuilder<RatingPersonCreatorRole> builder)
|
||||
{
|
||||
builder.ToTable("RatingsPersonCreatorRole");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRole)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.RatingPersonCreatorRole)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Rating)
|
||||
.IsRequired();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.ViewCount
|
||||
{
|
||||
public class ViewCountMedia : IEntity<ViewCountMedia>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long MediaId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Media.Media Media { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<ViewCountMedia>.Build(EntityTypeBuilder<ViewCountMedia> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsMedia");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.ViewCountsMedia)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.ViewCount
|
||||
{
|
||||
public class ViewCountPerson : IEntity<ViewCountPerson>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public long PersonId { get; set; }
|
||||
public DateOnly Date { get; set; }
|
||||
public long ViewCount { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Person.Person Person { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<ViewCountPerson>.Build(EntityTypeBuilder<ViewCountPerson> builder)
|
||||
{
|
||||
builder.ToTable("ViewCountsPerson");
|
||||
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Person)
|
||||
.WithMany(x => x.ViewCountsPerson)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Date)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.ViewCount)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(0);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user