2025-03-03 00:56:32 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2024-04-27 22:36:16 +02:00
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
2025-03-03 00:56:32 +01:00
|
|
|
using WatchIt.Database.Model.Genres;
|
2024-04-27 22:36:16 +02:00
|
|
|
|
2025-03-03 00:56:32 +01:00
|
|
|
namespace WatchIt.Database.Configuration.Genres;
|
2024-04-27 22:36:16 +02:00
|
|
|
|
|
|
|
|
public class GenreConfiguration : IEntityTypeConfiguration<Genre>
|
|
|
|
|
{
|
2025-03-03 00:56:32 +01:00
|
|
|
#region PUBLIC METHODS
|
|
|
|
|
|
2024-04-27 22:36:16 +02:00
|
|
|
public void Configure(EntityTypeBuilder<Genre> builder)
|
|
|
|
|
{
|
2025-03-03 00:56:32 +01:00
|
|
|
builder.ToTable("Genres", "genres");
|
|
|
|
|
|
|
|
|
|
// Id
|
2024-04-27 22:36:16 +02:00
|
|
|
builder.HasKey(x => x.Id);
|
|
|
|
|
builder.HasIndex(x => x.Id)
|
|
|
|
|
.IsUnique();
|
|
|
|
|
builder.Property(x => x.Id)
|
2025-03-03 00:56:32 +01:00
|
|
|
.IsRequired()
|
|
|
|
|
.UseIdentityAlwaysColumn();
|
2024-04-27 22:36:16 +02:00
|
|
|
|
2025-03-03 00:56:32 +01:00
|
|
|
// Name
|
2024-04-27 22:36:16 +02:00
|
|
|
builder.Property(x => x.Name)
|
|
|
|
|
.HasMaxLength(100)
|
|
|
|
|
.IsRequired();
|
|
|
|
|
|
2025-03-03 00:56:32 +01:00
|
|
|
// Version
|
|
|
|
|
builder.Property(b => b.Version)
|
|
|
|
|
.IsRowVersion();
|
2024-04-27 22:36:16 +02:00
|
|
|
}
|
2025-03-03 00:56:32 +01:00
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|