feat: created register method for entry

This commit is contained in:
Lisoveliy
2025-05-01 01:06:16 +03:00
parent 881ae85ef7
commit c09d17047d
4 changed files with 37 additions and 6 deletions

View File

@@ -8,4 +8,12 @@ class AppDbContext : DbContext
public DbSet<User> Users { get; set; }
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<User>()
.HasAlternateKey(b => b.TelegramId);
}
}

View File

@@ -1,9 +1,15 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.EntityFrameworkCore;
namespace JOBot.Backend.DAL.Models;
[PrimaryKey(nameof(Id))]
public class User
{
public Guid Id { get; set; }
public long TelegramId { get; set; }
[Key]
public required long TelegramId { get; set; }
public string? Username { get; set; }
public DateTime CreatedAt { get; set; } = DateTime.Now;
}