project reorganized
This commit is contained in:
@@ -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>());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user