project reorganized
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountConfiguration : IEntityTypeConfiguration<Model.Account.Account>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Account.Account> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Username)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Email)
|
||||
.HasMaxLength(320)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId);
|
||||
builder.Property(x => x.GenderId);
|
||||
|
||||
builder.HasOne(x => x.ProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Model.Account.Account>(e => e.ProfilePictureId);
|
||||
builder.Property(x => x.ProfilePictureId);
|
||||
|
||||
builder.HasOne(x => x.BackgroundPicture)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.BackgroundPictureId);
|
||||
builder.Property(x => x.BackgroundPictureId);
|
||||
|
||||
builder.Property(x => x.Password)
|
||||
.HasMaxLength(1000)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.LeftSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RightSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsAdmin)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.CreationDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.LastActive)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountProfilePictureConfiguration : IEntityTypeConfiguration<AccountProfilePicture>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AccountProfilePicture> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Account;
|
||||
|
||||
public class AccountRefreshTokenConfiguration : IEntityTypeConfiguration<AccountRefreshToken>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<AccountRefreshToken> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Account)
|
||||
.WithMany(x => x.AccountRefreshTokens)
|
||||
.HasForeignKey(x => x.AccountId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.AccountId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.ExpirationDate)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsExtendable)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class CountryConfiguration : IEntityTypeConfiguration<Country>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Country> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsHistorical)
|
||||
.HasDefaultValue(false)
|
||||
.IsRequired();
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.MediaProduction)
|
||||
.WithMany(x => x.ProductionCountries)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Country>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class GenderConfiguration : IEntityTypeConfiguration<Gender>
|
||||
{
|
||||
public void Configure(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();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Gender>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Common;
|
||||
using WatchIt.Database.Model.Media;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Common;
|
||||
|
||||
public class GenreConfiguration : IEntityTypeConfiguration<Genre>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Genre> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Media)
|
||||
.WithMany(x => x.Genres)
|
||||
.UsingEntity<MediaGenre>();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<Genre>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaConfiguration : IEntityTypeConfiguration<Model.Media.Media>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Media.Media> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Title)
|
||||
.HasMaxLength(250)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.OriginalTitle)
|
||||
.HasMaxLength(250);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.ReleaseDate);
|
||||
|
||||
builder.Property(x => x.Length);
|
||||
|
||||
builder.HasOne(x => x.MediaPosterImage)
|
||||
.WithOne(x => x.Media)
|
||||
.HasForeignKey<Model.Media.Media>(x => x.MediaPosterImageId);
|
||||
builder.Property(x => x.MediaPosterImageId);
|
||||
|
||||
// Navigation
|
||||
builder.HasMany(x => x.Genres)
|
||||
.WithMany(x => x.Media)
|
||||
.UsingEntity<MediaGenre>();
|
||||
builder.HasMany(x => x.ProductionCountries)
|
||||
.WithMany(x => x.MediaProduction)
|
||||
.UsingEntity<MediaProductionCountry>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaGenreConfiguration : IEntityTypeConfiguration<MediaGenre>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaGenre> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Genre)
|
||||
.WithMany(x => x.MediaGenres)
|
||||
.HasForeignKey(x => x.GenreId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.GenreId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaMovieConfiguration : IEntityTypeConfiguration<MediaMovie>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaMovie> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<MediaMovie>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Budget)
|
||||
.HasColumnType("money");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaPhotoImageConfiguration : IEntityTypeConfiguration<MediaPhotoImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaPhotoImage> 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.MediaPhotoImages)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.IsMediaBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
|
||||
builder.Property(x => x.IsUniversalBackground)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaPosterImageConfiguration : IEntityTypeConfiguration<MediaPosterImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaPosterImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaProductionCountryConfiguration : IEntityTypeConfiguration<MediaProductionCountry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaProductionCountry> builder)
|
||||
{
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Country)
|
||||
.WithMany(x => x.MediaProductionCountries)
|
||||
.HasForeignKey(x => x.CountryId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.CountryId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesConfiguration : IEntityTypeConfiguration<MediaSeries>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeries> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithOne()
|
||||
.HasForeignKey<MediaSeries>(x => x.Id)
|
||||
.IsRequired();
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.HasEnded)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesEpisodeConfiguration : IEntityTypeConfiguration<MediaSeriesEpisode>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeriesEpisode> 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.MediaSeriesEpisodes)
|
||||
.HasForeignKey(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesSeasonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
|
||||
builder.Property(x => x.IsSpecial)
|
||||
.IsRequired()
|
||||
.HasDefaultValue(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Media;
|
||||
|
||||
public class MediaSeriesSeasonConfiguration : IEntityTypeConfiguration<MediaSeriesSeason>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<MediaSeriesSeason> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.MediaSeries)
|
||||
.WithMany(x => x.MediaSeriesSeasons)
|
||||
.HasForeignKey(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaSeriesId)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Number)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonActorRoleConfiguration : IEntityTypeConfiguration<PersonActorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonActorRole> builder)
|
||||
{
|
||||
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.PersonActorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonActorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonActorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonActorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonActorRoleTypeConfiguration : IEntityTypeConfiguration<PersonActorRoleType>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonActorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<PersonActorRoleType>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonConfiguration : IEntityTypeConfiguration<Model.Person.Person>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Model.Person.Person> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.FullName)
|
||||
.HasMaxLength(200);
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.Property(x => x.BirthDate);
|
||||
|
||||
builder.Property(x => x.DeathDate);
|
||||
|
||||
builder.HasOne(x => x.Gender)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.GenderId);
|
||||
builder.Property(x => x.GenderId);
|
||||
|
||||
builder.HasOne(x => x.PersonPhoto)
|
||||
.WithOne(x => x.Person)
|
||||
.HasForeignKey<Model.Person.Person>(e => e.PersonPhotoId);
|
||||
builder.Property(x => x.PersonPhotoId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonCreatorRoleConfiguration : IEntityTypeConfiguration<PersonCreatorRole>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonCreatorRole> builder)
|
||||
{
|
||||
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.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.PersonId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.Media)
|
||||
.WithMany(x => x.PersonCreatorRoles)
|
||||
.HasForeignKey(x => x.MediaId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediaId)
|
||||
.IsRequired();
|
||||
|
||||
builder.HasOne(x => x.PersonCreatorRoleType)
|
||||
.WithMany()
|
||||
.HasForeignKey(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.PersonCreatorRoleTypeId)
|
||||
.IsRequired();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
using WatchIt.Database.Model.Seeding;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonCreatorRoleTypeConfiguration : IEntityTypeConfiguration<PersonCreatorRoleType>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonCreatorRoleType> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Name)
|
||||
.HasMaxLength(100)
|
||||
.IsRequired();
|
||||
|
||||
// Data
|
||||
builder.HasData(DataReader.Read<PersonCreatorRoleType>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Person;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Person;
|
||||
|
||||
public class PersonPhotoImageConfiguration : IEntityTypeConfiguration<PersonPhotoImage>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<PersonPhotoImage> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaConfiguration : IEntityTypeConfiguration<RatingMedia>
|
||||
{
|
||||
public void Configure(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaSeriesEpisodeConfiguration : IEntityTypeConfiguration<RatingMediaSeriesEpisode>
|
||||
{
|
||||
public void Configure(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingMediaSeriesSeasonConfiguration : IEntityTypeConfiguration<RatingMediaSeriesSeason>
|
||||
{
|
||||
public void Configure(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingPersonActorRoleConfiguration : IEntityTypeConfiguration<RatingPersonActorRole>
|
||||
{
|
||||
public void Configure(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Rating;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.Rating;
|
||||
|
||||
public class RatingPersonCreatorRoleConfiguration : IEntityTypeConfiguration<RatingPersonCreatorRole>
|
||||
{
|
||||
public void Configure(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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.ViewCount;
|
||||
|
||||
public class ViewCountMediaConfiguration : IEntityTypeConfiguration<ViewCountMedia>
|
||||
{
|
||||
public void Configure(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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.ViewCount;
|
||||
|
||||
namespace WatchIt.Database.Model.Configuration.ViewCount;
|
||||
|
||||
public class ViewCountPersonConfiguration : IEntityTypeConfiguration<ViewCountPerson>
|
||||
{
|
||||
public void Configure(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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WatchIt.Database.Model.Seeding\WatchIt.Database.Model.Seeding.csproj" />
|
||||
<ProjectReference Include="..\WatchIt.Database.Model\WatchIt.Database.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user