table added
This commit is contained in:
99
WatchIt.Database/WatchIt.Database.Model/Account/Account.cs
Normal file
99
WatchIt.Database/WatchIt.Database.Model/Account/Account.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
public class Account : IEntity<Account>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public long Id { get; set; }
|
||||
public string Username { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Description { get; set; }
|
||||
public Guid AccountProfilePictureId { get; set; }
|
||||
|
||||
// BackgroundPicture key to MovieImages
|
||||
// public Guid BackgroundPicture { get; set; }
|
||||
|
||||
public byte[] Password { get; set; }
|
||||
public string LeftSalt { get; set; }
|
||||
public string RightSalt { get; set; }
|
||||
public bool IsAdmin { get; set; } = false;
|
||||
public DateTimeOffset CreationDate { get; set; }
|
||||
public DateTimeOffset LastActive { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public AccountProfilePicture AccountProfilePicture { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
static void IEntity<Account>.Build(EntityTypeBuilder<Account> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Username)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Email)
|
||||
.HasMaxLength(320)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Description)
|
||||
.HasMaxLength(1000);
|
||||
|
||||
builder.HasOne(x => x.AccountProfilePicture)
|
||||
.WithOne(x => x.Account)
|
||||
.HasForeignKey<Account>(e => e.AccountProfilePictureId);
|
||||
builder.Property(x => x.AccountProfilePictureId);
|
||||
|
||||
builder.Property(x => x.Password)
|
||||
.HasMaxLength(1000)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.LeftSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.RightSalt)
|
||||
.HasMaxLength(20)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.IsAdmin)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.CreationDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
builder.Property(x => x.LastActive)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WatchIt.Database.Model.Account
|
||||
{
|
||||
public class AccountProfilePicture : IEntity<AccountProfilePicture>
|
||||
{
|
||||
#region PROPERTIES
|
||||
|
||||
public Guid Id { get; set; }
|
||||
public byte[] Image { get; set; }
|
||||
public string MimeType { get; set; }
|
||||
public DateTimeOffset UploadDate { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region NAVIGATION
|
||||
|
||||
public Account Account { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PUBLIC METHODS
|
||||
|
||||
static void IEntity<AccountProfilePicture>.Build(EntityTypeBuilder<AccountProfilePicture> builder)
|
||||
{
|
||||
builder.HasKey(x => x.Id);
|
||||
builder.HasIndex(x => x.Id)
|
||||
.IsUnique();
|
||||
builder.Property(x => x.Id)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.Image)
|
||||
.HasMaxLength(-1)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.MimeType)
|
||||
.HasMaxLength(50)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(x => x.UploadDate)
|
||||
.IsRequired()
|
||||
.HasDefaultValueSql("now()");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
20
WatchIt.Database/WatchIt.Database.Model/EntityBuilder.cs
Normal file
20
WatchIt.Database/WatchIt.Database.Model/EntityBuilder.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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
|
||||
{
|
||||
public static class EntityBuilder
|
||||
{
|
||||
#region PUBLIC METHODS
|
||||
|
||||
public static void Build<T>(ModelBuilder builder) where T : class, IEntity<T> => Build<T>(builder.Entity<T>());
|
||||
public static void Build<T>(EntityTypeBuilder<T> builder) where T : class, IEntity<T> => T.Build(builder);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
19
WatchIt.Database/WatchIt.Database.Model/IEntity.cs
Normal file
19
WatchIt.Database/WatchIt.Database.Model/IEntity.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
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
|
||||
{
|
||||
public interface IEntity<T> where T : class
|
||||
{
|
||||
#region METHODS
|
||||
|
||||
static abstract void Build(EntityTypeBuilder<T> builder);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
48
WatchIt.Database/WatchIt.Database/DatabaseContext.cs
Normal file
48
WatchIt.Database/WatchIt.Database/DatabaseContext.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using WatchIt.Database.Model;
|
||||
using WatchIt.Database.Model.Account;
|
||||
|
||||
namespace WatchIt.Database
|
||||
{
|
||||
public class DatabaseContext : DbContext
|
||||
{
|
||||
#region CONSTRUCTORS
|
||||
|
||||
public DatabaseContext() { }
|
||||
|
||||
public DatabaseContext(DbContextOptions<DatabaseContext> options) : base(options) { }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region PROPERTIES
|
||||
|
||||
// Account
|
||||
public virtual DbSet<Account> Accounts { get; set; }
|
||||
public virtual DbSet<AccountProfilePicture> AccountProfilePictures { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region METHODS
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) => optionsBuilder.UseNpgsql("name=Default");
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// Account
|
||||
EntityBuilder.Build<Account>(modelBuilder);
|
||||
EntityBuilder.Build<AccountProfilePicture>(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
141
WatchIt.Database/WatchIt.Database/Migrations/20240317125055_Migration1.Designer.cs
generated
Normal file
141
WatchIt.Database/WatchIt.Database/Migrations/20240317125055_Migration1.Designer.cs
generated
Normal file
@@ -0,0 +1,141 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using WatchIt.Database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WatchIt.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20240317125055_Migration1")]
|
||||
partial class Migration1
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Guid>("AccountProfilePictureId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("CreationDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("character varying(1000)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(320)
|
||||
.HasColumnType("character varying(320)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("LastActive")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<string>("LeftSalt")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("character varying(20)");
|
||||
|
||||
b.Property<byte[]>("Password")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<string>("RightSalt")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("character varying(20)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AccountProfilePictureId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("Id")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte[]>("Image")
|
||||
.IsRequired()
|
||||
.HasMaxLength(-1)
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<string>("MimeType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.Property<DateTimeOffset>("UploadDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Id")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("AccountProfilePictures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
|
||||
{
|
||||
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "AccountProfilePicture")
|
||||
.WithOne("Account")
|
||||
.HasForeignKey("WatchIt.Database.Model.Account.Account", "AccountProfilePictureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AccountProfilePicture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
|
||||
{
|
||||
b.Navigation("Account")
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WatchIt.Database.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Migration1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AccountProfilePictures",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Image = table.Column<byte[]>(type: "bytea", maxLength: -1, nullable: false),
|
||||
MimeType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||
UploadDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AccountProfilePictures", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Accounts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Username = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
||||
Email = table.Column<string>(type: "character varying(320)", maxLength: 320, nullable: false),
|
||||
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
|
||||
AccountProfilePictureId = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
Password = table.Column<byte[]>(type: "bytea", maxLength: 1000, nullable: false),
|
||||
LeftSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||
RightSalt = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
||||
IsAdmin = table.Column<bool>(type: "boolean", nullable: false),
|
||||
CreationDate = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()"),
|
||||
LastActive = table.Column<DateTimeOffset>(type: "timestamp with time zone", nullable: false, defaultValueSql: "now()")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Accounts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Accounts_AccountProfilePictures_AccountProfilePictureId",
|
||||
column: x => x.AccountProfilePictureId,
|
||||
principalTable: "AccountProfilePictures",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AccountProfilePictures_Id",
|
||||
table: "AccountProfilePictures",
|
||||
column: "Id",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Accounts_AccountProfilePictureId",
|
||||
table: "Accounts",
|
||||
column: "AccountProfilePictureId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Accounts_Id",
|
||||
table: "Accounts",
|
||||
column: "Id",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Accounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AccountProfilePictures");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using WatchIt.Database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace WatchIt.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
partial class DatabaseContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "8.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<Guid>("AccountProfilePictureId")
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<DateTimeOffset>("CreationDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("character varying(1000)");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.IsRequired()
|
||||
.HasMaxLength(320)
|
||||
.HasColumnType("character varying(320)");
|
||||
|
||||
b.Property<bool>("IsAdmin")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateTimeOffset>("LastActive")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.Property<string>("LeftSalt")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("character varying(20)");
|
||||
|
||||
b.Property<byte[]>("Password")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1000)
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<string>("RightSalt")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("character varying(20)");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AccountProfilePictureId")
|
||||
.IsUnique();
|
||||
|
||||
b.HasIndex("Id")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Accounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("uuid");
|
||||
|
||||
b.Property<byte[]>("Image")
|
||||
.IsRequired()
|
||||
.HasMaxLength(-1)
|
||||
.HasColumnType("bytea");
|
||||
|
||||
b.Property<string>("MimeType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)");
|
||||
|
||||
b.Property<DateTimeOffset>("UploadDate")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("now()");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("Id")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("AccountProfilePictures");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.Account", b =>
|
||||
{
|
||||
b.HasOne("WatchIt.Database.Model.Account.AccountProfilePicture", "AccountProfilePicture")
|
||||
.WithOne("Account")
|
||||
.HasForeignKey("WatchIt.Database.Model.Account.Account", "AccountProfilePictureId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("AccountProfilePicture");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("WatchIt.Database.Model.Account.AccountProfilePicture", b =>
|
||||
{
|
||||
b.Navigation("Account")
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
31
WatchIt.Database/WatchIt.Database/WatchIt.Database.csproj
Normal file
31
WatchIt.Database/WatchIt.Database/WatchIt.Database.csproj
Normal file
@@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql" Version="8.0.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WatchIt.Database.Model\WatchIt.Database.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user