From 725eab7e7f7f6e0148845e88e4fe6d2ae11167d7 Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 3 Apr 2025 19:38:58 -0400 Subject: [PATCH] Change id types --- Icarus/Database/Contexts/UserContext.cs | 8 ++++++++ Models/LoginResult.cs | 2 +- Models/User.cs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Icarus/Database/Contexts/UserContext.cs b/Icarus/Database/Contexts/UserContext.cs index 3bb0cec..818ad3d 100644 --- a/Icarus/Database/Contexts/UserContext.cs +++ b/Icarus/Database/Contexts/UserContext.cs @@ -23,6 +23,14 @@ public class UserContext : DbContext { modelBuilder.Entity() .ToTable("User"); + + modelBuilder.Entity(entity => +{ + entity.HasKey(e => e.Id); + + entity.Property(e => e.Id) + .HasColumnType("binary(16)"); // **** Map Guid to BINARY(16) **** +}); modelBuilder.Entity() .Property(u => u.LastLogin).IsRequired(false); modelBuilder.Entity() diff --git a/Models/LoginResult.cs b/Models/LoginResult.cs index d8d4da7..bf7942a 100644 --- a/Models/LoginResult.cs +++ b/Models/LoginResult.cs @@ -6,7 +6,7 @@ public class LoginResult : BaseResult { #region Properties [JsonProperty("user_id")] - public int UserId { get; set; } + public Guid UserId { get; set; } [JsonProperty("username")] public string? Username { get; set; } [JsonProperty("token")] diff --git a/Models/User.cs b/Models/User.cs index 95182f4..b2d0721 100644 --- a/Models/User.cs +++ b/Models/User.cs @@ -12,7 +12,7 @@ public class User [JsonProperty("id")] [Column("Id")] [Key] - public int Id { get; set; } + public Guid Id { get; set; } [JsonProperty("username")] public string? Username { get; set; } [JsonProperty("password")]