This commit is contained in:
ani_konarcheva@abv.bg
2022-03-26 11:39:34 +02:00
parent f2a4fd68a0
commit 0c9d39d506
5 changed files with 54 additions and 6 deletions

View File

@@ -3,10 +3,11 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
namespace Data.Entities namespace Data.Entities
{ {
public class User public class User : IdentityUser<string>
{ {
public enum RoleEnum public enum RoleEnum
{ {
@@ -14,8 +15,7 @@ namespace Data.Entities
Manager Manager
} }
public override string Id { get; set; }
public int Id { get; set; }
public string Username { get; set; } public string Username { get; set; }
@@ -27,9 +27,9 @@ namespace Data.Entities
public int PersonalNumber { get; set; } public int PersonalNumber { get; set; }
public int PhoneNumber { get; set; } public override string PhoneNumber { get; set; }
public string Email { get; set; } public override string Email { get; set; }
public RoleEnum Role { get; set; } public RoleEnum Role { get; set; }
} }

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Data.Initializers
{
class RentACarDbCreateIfNotExistsInitializer
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Data.Initializers
{
class RentACarDbDropCreateIfModelChanges
{
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Data.Initializers
{
class Seeder
{
}
}

View File

@@ -1,15 +1,27 @@
using System; using System;
using Data.Entities; using Data.Entities;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace Data namespace Data
{ {
public class RentACarDbContext : DbContext public class RentACarDbContext : IdentityDbContext<User, IdentityRole, string>
{ {
public virtual DbSet<User> Users { get; set; } public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Car> Cars { get; set; } public virtual DbSet<Car> Cars { get; set; }
public virtual DbSet<Rents> Rents { get; set; } public virtual DbSet<Rents> Rents { get; set; }
public RentACarDbContext()
{
}
public RentACarDbContext(DbContextOptions<RentACarDbContext> dbContextOptions) : base(dbContextOptions)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
if (!optionsBuilder.IsConfigured) if (!optionsBuilder.IsConfigured)