Refactoring, database structure changed
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using WatchIt.Database.Model.Media;
|
||||
|
||||
namespace WatchIt.Database.Configuration.Media;
|
||||
|
||||
public class MediumPictureConfiguration : ImageEntityConfiguration<MediumPicture>
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public override void Configure(EntityTypeBuilder<MediumPicture> builder)
|
||||
{
|
||||
builder.ToTable("MediumPictures", "media");
|
||||
|
||||
// Medium
|
||||
builder.HasKey(x => x.MediumId);
|
||||
builder.HasIndex(x => x.MediumId)
|
||||
.IsUnique();
|
||||
builder.HasOne(x => x.Medium)
|
||||
.WithOne(x => x.Picture)
|
||||
.HasForeignKey<MediumPicture>(x => x.MediumId)
|
||||
.IsRequired();
|
||||
builder.Property(x => x.MediumId)
|
||||
.IsRequired();
|
||||
|
||||
// Version
|
||||
builder.Property(b => b.Version)
|
||||
.IsRowVersion();
|
||||
|
||||
// Generic properties
|
||||
base.Configure(builder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user