2023-08-11 15:51:20 +01:00
|
|
|
using Microsoft.EntityFrameworkCore;
|
2023-08-06 15:57:23 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
2023-08-12 20:13:47 +01:00
|
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
2023-08-06 15:57:23 +01:00
|
|
|
|
2023-08-13 17:33:54 +01:00
|
|
|
namespace OliverBooth.Data.Blog.Configuration;
|
2023-08-06 15:57:23 +01:00
|
|
|
|
|
|
|
internal sealed class BlogPostConfiguration : IEntityTypeConfiguration<BlogPost>
|
|
|
|
{
|
|
|
|
/// <inheritdoc />
|
|
|
|
public void Configure(EntityTypeBuilder<BlogPost> builder)
|
|
|
|
{
|
|
|
|
builder.ToTable("BlogPost");
|
|
|
|
builder.HasKey(e => e.Id);
|
|
|
|
|
2023-08-11 14:09:13 +01:00
|
|
|
builder.Property(e => e.Id);
|
2023-08-06 15:57:23 +01:00
|
|
|
builder.Property(e => e.WordPressId).IsRequired(false);
|
|
|
|
builder.Property(e => e.Slug).HasMaxLength(100).IsRequired();
|
|
|
|
builder.Property(e => e.AuthorId).IsRequired();
|
|
|
|
builder.Property(e => e.Published).IsRequired();
|
2023-08-07 23:42:59 +01:00
|
|
|
builder.Property(e => e.Updated).IsRequired(false);
|
2023-08-06 15:57:23 +01:00
|
|
|
builder.Property(e => e.Title).HasMaxLength(255).IsRequired();
|
|
|
|
builder.Property(e => e.Body).IsRequired();
|
2023-08-08 00:20:21 +01:00
|
|
|
builder.Property(e => e.IsRedirect).IsRequired();
|
2023-08-12 20:13:47 +01:00
|
|
|
builder.Property(e => e.RedirectUrl).HasConversion<UriToStringConverter>().HasMaxLength(255).IsRequired(false);
|
2023-08-08 00:20:38 +01:00
|
|
|
builder.Property(e => e.EnableComments).IsRequired();
|
2023-08-08 12:39:49 +01:00
|
|
|
builder.Property(e => e.DisqusDomain).IsRequired(false);
|
|
|
|
builder.Property(e => e.DisqusIdentifier).IsRequired(false);
|
|
|
|
builder.Property(e => e.DisqusPath).IsRequired(false);
|
2023-08-20 14:22:52 +01:00
|
|
|
builder.Property(e => e.Visibility).HasConversion(new EnumToStringConverter<BlogPostVisibility>()).IsRequired();
|
|
|
|
builder.Property(e => e.Password).HasMaxLength(255).IsRequired(false);
|
2023-08-06 15:57:23 +01:00
|
|
|
}
|
|
|
|
}
|