2023-12-14 16:03:24 +00:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
2024-03-02 00:43:56 +00:00
|
|
|
using OliverBooth.Common.Data.Web.Books;
|
2023-12-14 16:03:24 +00:00
|
|
|
|
2024-03-02 00:43:56 +00:00
|
|
|
namespace OliverBooth.Common.Data.Web.Configuration;
|
2023-12-14 16:03:24 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Represents the configuration for the <see cref="Book" /> entity.
|
|
|
|
/// </summary>
|
|
|
|
internal sealed class BookConfiguration : IEntityTypeConfiguration<Book>
|
|
|
|
{
|
|
|
|
/// <inheritdoc />
|
|
|
|
public void Configure(EntityTypeBuilder<Book> builder)
|
|
|
|
{
|
|
|
|
builder.ToTable("Book");
|
|
|
|
builder.HasKey(entry => entry.Isbn);
|
|
|
|
|
|
|
|
builder.Property(entry => entry.Isbn).IsRequired();
|
|
|
|
builder.Property(entry => entry.Title).IsRequired();
|
|
|
|
builder.Property(entry => entry.Author).IsRequired();
|
|
|
|
builder.Property(entry => entry.State).HasConversion<EnumToStringConverter<BookState>>().IsRequired();
|
|
|
|
}
|
|
|
|
}
|