Add initial implementation of API, database, and user management components.
This commit is contained in:
32
MikrocopDb/AppDbContext.cs
Normal file
32
MikrocopDb/AppDbContext.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MikrocopDb.Entities;
|
||||
|
||||
namespace MikrocopDb;
|
||||
|
||||
public sealed class AppDbContext : DbContext
|
||||
{
|
||||
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<UserEntity> Users => Set<UserEntity>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<UserEntity>(entity =>
|
||||
{
|
||||
entity.HasKey(x => x.Id);
|
||||
entity.Property(x => x.UserName).HasMaxLength(100).IsRequired();
|
||||
entity.Property(x => x.FullName).HasMaxLength(200).IsRequired();
|
||||
entity.Property(x => x.Email).HasMaxLength(200).IsRequired();
|
||||
entity.Property(x => x.MobileNumber).HasMaxLength(30).IsRequired();
|
||||
entity.Property(x => x.Language).HasMaxLength(20).IsRequired();
|
||||
entity.Property(x => x.Culture).HasMaxLength(20).IsRequired();
|
||||
entity.Property(x => x.PasswordHash).IsRequired();
|
||||
entity.Property(x => x.PasswordSalt).HasMaxLength(128).IsRequired();
|
||||
|
||||
entity.HasIndex(x => x.UserName).IsUnique();
|
||||
entity.HasIndex(x => x.Email).IsUnique();
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user