new tables

This commit is contained in:
2024-03-21 18:33:34 +01:00
Unverified
parent a5b7efdff6
commit 3869efbc67
30 changed files with 3471 additions and 1364 deletions

View File

@@ -0,0 +1,62 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WatchIt.Database.Model.ViewCount
{
public class ViewCountPerson : IEntity<ViewCountPerson>
{
#region PROPERTIES
public Guid Id { get; set; }
public long PersonId { get; set; }
public DateOnly Date { get; set; }
public long ViewCount { get; set; }
#endregion
#region NAVIGATION
public Person.Person Person { get; set; }
#endregion
#region PUBLIC METHODS
static void IEntity<ViewCountPerson>.Build(EntityTypeBuilder<ViewCountPerson> builder)
{
builder.ToTable("ViewCountsPerson");
builder.HasKey(x => x.Id);
builder.HasIndex(x => x.Id)
.IsUnique();
builder.Property(x => x.Id)
.IsRequired();
builder.HasOne(x => x.Person)
.WithMany(x => x.ViewCountsPerson)
.HasForeignKey(x => x.PersonId)
.IsRequired();
builder.Property(x => x.PersonId)
.IsRequired();
builder.Property(x => x.Date)
.IsRequired()
.HasDefaultValueSql("now()");
builder.Property(x => x.ViewCount)
.IsRequired()
.HasDefaultValue(0);
}
#endregion
}
}