Files
WatchIt/WatchIt.Database/Configuration/Genres/GenreConfiguration.cs

34 lines
868 B
C#
Raw Normal View History

using Microsoft.EntityFrameworkCore;
2024-04-27 22:36:16 +02:00
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using WatchIt.Database.Model.Genres;
2024-04-27 22:36:16 +02:00
namespace WatchIt.Database.Configuration.Genres;
2024-04-27 22:36:16 +02:00
public class GenreConfiguration : IEntityTypeConfiguration<Genre>
{
#region PUBLIC METHODS
2024-04-27 22:36:16 +02:00
public void Configure(EntityTypeBuilder<Genre> builder)
{
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)
.IsRequired()
.UseIdentityAlwaysColumn();
2024-04-27 22:36:16 +02:00
// Name
2024-04-27 22:36:16 +02:00
builder.Property(x => x.Name)
.HasMaxLength(100)
.IsRequired();
// Version
builder.Property(b => b.Version)
.IsRowVersion();
2024-04-27 22:36:16 +02:00
}
#endregion
}