diff --git a/src/AliasDb/AliasDbContext.cs b/src/AliasDb/AliasDbContext.cs
index 0525e09e0..36c58287d 100644
--- a/src/AliasDb/AliasDbContext.cs
+++ b/src/AliasDb/AliasDbContext.cs
@@ -4,6 +4,9 @@
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information.
//
//-----------------------------------------------------------------------
+
+using Microsoft.Extensions.Configuration;
+
namespace AliasDb;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
@@ -118,4 +121,24 @@ public class AliasDbContext : IdentityDbContext
.HasForeignKey(p => p.UserId)
.IsRequired();
}
+
+ ///
+ /// Sets up the connection string if it is not already configured.
+ ///
+ /// DbContextOptionsBuilder instance.
+ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ {
+ // If the options are not already configured, use the appsettings.json file.
+ if (!optionsBuilder.IsConfigured)
+ {
+ var configuration = new ConfigurationBuilder()
+ .SetBasePath(Directory.GetCurrentDirectory())
+ .AddJsonFile("appsettings.json")
+ .Build();
+
+ optionsBuilder
+ .UseSqlite(configuration.GetConnectionString("AliasDbContext"))
+ .UseLazyLoadingProxies();
+ }
+ }
}
diff --git a/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.Designer.cs b/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.Designer.cs
new file mode 100644
index 000000000..4ed4f6632
--- /dev/null
+++ b/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.Designer.cs
@@ -0,0 +1,540 @@
+//
+using System;
+using AliasDb;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace AliasDb.Migrations
+{
+ [DbContext(typeof(AliasDbContext))]
+ [Migration("20240616200303_ChangeColumnDefinitions")]
+ partial class ChangeColumnDefinitions
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "8.0.6")
+ .HasAnnotation("Proxies:ChangeTracking", false)
+ .HasAnnotation("Proxies:CheckEquality", false)
+ .HasAnnotation("Proxies:LazyLoading", true);
+
+ modelBuilder.Entity("AliasDb.AspNetUserRefreshToken", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("DeviceIdentifier")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("ExpireDate")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserRefreshTokens");
+ });
+
+ modelBuilder.Entity("AliasDb.Identity", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("AddressCity")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("AddressCountry")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("AddressState")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("AddressStreet")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("AddressZipCode")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("BankAccountIBAN")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("BirthDate")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("DefaultPasswordId")
+ .HasColumnType("TEXT");
+
+ b.Property("EmailPrefix")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("Gender")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("Hobbies")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("LastName")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("NickName")
+ .HasMaxLength(255)
+ .HasColumnType("VARCHAR");
+
+ b.Property("PhoneMobile")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DefaultPasswordId");
+
+ b.ToTable("Identities");
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Description")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("IdentityId")
+ .HasColumnType("TEXT");
+
+ b.Property("ServiceId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IdentityId");
+
+ b.HasIndex("ServiceId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Logins");
+ });
+
+ modelBuilder.Entity("AliasDb.Password", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("LoginId")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LoginId");
+
+ b.ToTable("Passwords");
+ });
+
+ modelBuilder.Entity("AliasDb.Service", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Logo")
+ .HasColumnType("BLOB");
+
+ b.Property("Name")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("TEXT");
+
+ b.Property("Url")
+ .HasMaxLength(255)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Services");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("AspNetRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("TEXT");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("TEXT");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.Property("PasswordHash")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("TEXT");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("INTEGER");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("TEXT");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("AspNetUsers", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClaimType")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimValue")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property("ProviderKey")
+ .HasColumnType("TEXT");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("RoleId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("TEXT");
+
+ b.Property("LoginProvider")
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .HasColumnType("TEXT");
+
+ b.Property("Value")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens", (string)null);
+ });
+
+ modelBuilder.Entity("AliasDb.AspNetUserRefreshToken", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasDb.Identity", b =>
+ {
+ b.HasOne("AliasDb.Password", "DefaultPassword")
+ .WithMany()
+ .HasForeignKey("DefaultPasswordId")
+ .OnDelete(DeleteBehavior.SetNull);
+
+ b.Navigation("DefaultPassword");
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.HasOne("AliasDb.Identity", "Identity")
+ .WithMany()
+ .HasForeignKey("IdentityId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("AliasDb.Service", "Service")
+ .WithMany()
+ .HasForeignKey("ServiceId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Identity");
+
+ b.Navigation("Service");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("AliasDb.Password", b =>
+ {
+ b.HasOne("AliasDb.Login", "Login")
+ .WithMany("Passwords")
+ .HasForeignKey("LoginId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Login");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("AliasDb.Login", b =>
+ {
+ b.Navigation("Passwords");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.cs b/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.cs
new file mode 100644
index 000000000..097c54973
--- /dev/null
+++ b/src/AliasDb/Migrations/20240616200303_ChangeColumnDefinitions.cs
@@ -0,0 +1,62 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace AliasDb.Migrations
+{
+ ///
+ public partial class ChangeColumnDefinitions : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "LastName",
+ table: "Identities",
+ type: "VARCHAR",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "VARCHAR",
+ oldMaxLength: 255);
+
+ migrationBuilder.AlterColumn(
+ name: "FirstName",
+ table: "Identities",
+ type: "VARCHAR",
+ maxLength: 255,
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "VARCHAR",
+ oldMaxLength: 255);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "LastName",
+ table: "Identities",
+ type: "VARCHAR",
+ maxLength: 255,
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "VARCHAR",
+ oldMaxLength: 255,
+ oldNullable: true);
+
+ migrationBuilder.AlterColumn(
+ name: "FirstName",
+ table: "Identities",
+ type: "VARCHAR",
+ maxLength: 255,
+ nullable: false,
+ defaultValue: "",
+ oldClrType: typeof(string),
+ oldType: "VARCHAR",
+ oldMaxLength: 255,
+ oldNullable: true);
+ }
+ }
+}
diff --git a/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs b/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
index 9f39aa57c..6abdf3973 100644
--- a/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
+++ b/src/AliasDb/Migrations/AliasDbContextModelSnapshot.cs
@@ -16,12 +16,12 @@ namespace AliasDb.Migrations
{
#pragma warning disable 612, 618
modelBuilder
- .HasAnnotation("ProductVersion", "8.0.5")
+ .HasAnnotation("ProductVersion", "8.0.6")
.HasAnnotation("Proxies:ChangeTracking", false)
.HasAnnotation("Proxies:CheckEquality", false)
.HasAnnotation("Proxies:LazyLoading", true);
- modelBuilder.Entity("AliasDb.AspNetUserRefreshTokens", b =>
+ modelBuilder.Entity("AliasDb.AspNetUserRefreshToken", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
@@ -100,7 +100,6 @@ namespace AliasDb.Migrations
.HasColumnType("TEXT");
b.Property("FirstName")
- .IsRequired()
.HasMaxLength(255)
.HasColumnType("VARCHAR");
@@ -113,7 +112,6 @@ namespace AliasDb.Migrations
.HasColumnType("TEXT");
b.Property("LastName")
- .IsRequired()
.HasMaxLength(255)
.HasColumnType("VARCHAR");
@@ -419,7 +417,7 @@ namespace AliasDb.Migrations
b.ToTable("AspNetUserTokens", (string)null);
});
- modelBuilder.Entity("AliasDb.AspNetUserRefreshTokens", b =>
+ modelBuilder.Entity("AliasDb.AspNetUserRefreshToken", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User")
.WithMany()