Na most működik az API + adatbázis

This commit is contained in:
2025-01-15 14:01:58 +01:00
parent 474dce1aa7
commit a2906cc113
17 changed files with 283 additions and 23 deletions
+6
View File
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WorkFlowCheck.DL.Configurations;
namespace WorkFlowCheck.DL
{
@@ -15,5 +16,10 @@ namespace WorkFlowCheck.DL
}
public DbSet<Entities.User> Users { get; set; } = null!;
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfiguration(new UserTypeConfiguration());
}
}
}
@@ -0,0 +1,21 @@
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 WorkFlowCheck.DL.Configurations
{
public class UserTypeConfiguration : IEntityTypeConfiguration<Entities.User>
{
public void Configure(EntityTypeBuilder<Entities.User> builder)
{
builder.ToTable("Users");
builder.HasKey(e => e.Id);
builder.Property(e => e.Id).ValueGeneratedOnAdd();
}
}
}
+5 -2
View File
@@ -1,9 +1,12 @@
namespace WorkFlowCheck.DL.Entities
using System.ComponentModel.DataAnnotations.Schema;
namespace WorkFlowCheck.DL.Entities
{
public class User
{
public int Id { get; set; }
public string Name { get; set; } = null!;
public string Email { get; set; } = null!;
public string FirstName { get; set; } = null!;
public string LastName { get; set; } = null!;
}
}