diff --git a/Day03 Demo Solution.sln b/Day03 Demo Solution.sln
new file mode 100644
index 0000000..59022b1
--- /dev/null
+++ b/Day03 Demo Solution.sln
@@ -0,0 +1,37 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.6.33829.357
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo.PL", "Demo.PL\Demo.PL.csproj", "{0244FE80-08B4-4EEF-8075-8A935AA5B75C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo.DAL", "Demo.DAL\Demo.DAL.csproj", "{F5CC6B65-7E76-4ACE-BE99-7320C1F1103C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Demo.BLL", "Demo.BLL\Demo.BLL.csproj", "{B9572953-D43F-4ECE-BD1B-5D75E5FAA82C}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {0244FE80-08B4-4EEF-8075-8A935AA5B75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0244FE80-08B4-4EEF-8075-8A935AA5B75C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0244FE80-08B4-4EEF-8075-8A935AA5B75C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0244FE80-08B4-4EEF-8075-8A935AA5B75C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F5CC6B65-7E76-4ACE-BE99-7320C1F1103C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F5CC6B65-7E76-4ACE-BE99-7320C1F1103C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F5CC6B65-7E76-4ACE-BE99-7320C1F1103C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F5CC6B65-7E76-4ACE-BE99-7320C1F1103C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B9572953-D43F-4ECE-BD1B-5D75E5FAA82C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B9572953-D43F-4ECE-BD1B-5D75E5FAA82C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B9572953-D43F-4ECE-BD1B-5D75E5FAA82C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B9572953-D43F-4ECE-BD1B-5D75E5FAA82C}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1B503294-ED7B-4924-A315-70C5E013F91E}
+ EndGlobalSection
+EndGlobal
diff --git a/Demo.BLL/Demo.BLL.csproj b/Demo.BLL/Demo.BLL.csproj
new file mode 100644
index 0000000..09099e5
--- /dev/null
+++ b/Demo.BLL/Demo.BLL.csproj
@@ -0,0 +1,11 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
diff --git a/Demo.BLL/Interfaces/IDepartmentRepository.cs b/Demo.BLL/Interfaces/IDepartmentRepository.cs
new file mode 100644
index 0000000..75d0e7c
--- /dev/null
+++ b/Demo.BLL/Interfaces/IDepartmentRepository.cs
@@ -0,0 +1,15 @@
+using Demo.DAL;
+using Demo.DAL.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Interfaces
+{
+ public interface IDepartmentRepository : IGenericRepository
+ {
+
+ }
+}
diff --git a/Demo.BLL/Interfaces/IEmployeeRepository.cs b/Demo.BLL/Interfaces/IEmployeeRepository.cs
new file mode 100644
index 0000000..f5b98f0
--- /dev/null
+++ b/Demo.BLL/Interfaces/IEmployeeRepository.cs
@@ -0,0 +1,19 @@
+using Demo.DAL;
+using Demo.DAL.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Interfaces
+{
+ public interface IEmployeeRepository : IGenericRepository
+ {
+
+ //I use IQueryable not IEnumerable because I need make Filteration
+ IQueryable GetEmployeeByaddress(string address);
+
+ IQueryable SearchByName(string name);
+ }
+}
diff --git a/Demo.BLL/Interfaces/IGenericRepository.cs b/Demo.BLL/Interfaces/IGenericRepository.cs
new file mode 100644
index 0000000..dc1dde6
--- /dev/null
+++ b/Demo.BLL/Interfaces/IGenericRepository.cs
@@ -0,0 +1,21 @@
+using Demo.DAL.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Interfaces
+{
+ public interface IGenericRepository where T : class
+ {
+ //Async => Wrapping to each methods at ( Task)
+ Task> GetAll();
+
+ Task Get(int id);
+
+ void Add(T item);
+ void Update(T item);
+ void Delete(T item);
+ }
+}
diff --git a/Demo.BLL/Interfaces/IUnitOfWork.cs b/Demo.BLL/Interfaces/IUnitOfWork.cs
new file mode 100644
index 0000000..97666fb
--- /dev/null
+++ b/Demo.BLL/Interfaces/IUnitOfWork.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Interfaces
+{
+ //signature for Property for each Repository
+ public interface IUnitOfWork : IAsyncDisposable
+ {
+ public IEmployeeRepository EmployeeRepository { get; set; }
+
+ public IDepartmentRepository DepartmentRepository { get; set; }
+
+ //signature for Method => (Complete) that represent SaveChanges at DBContext
+ //return int => Number of rows that had affect ,
+ Task< int> Complete();
+
+
+ }
+}
diff --git a/Demo.BLL/Repositories/DepartmentRepository.cs b/Demo.BLL/Repositories/DepartmentRepository.cs
new file mode 100644
index 0000000..39347e3
--- /dev/null
+++ b/Demo.BLL/Repositories/DepartmentRepository.cs
@@ -0,0 +1,19 @@
+using Demo.BLL.Interfaces;
+using Demo.DAL.Contexts;
+using Demo.DAL.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Repositories
+{
+ public class DepartmentRepository : GenericRepository,IDepartmentRepository
+ {
+ public DepartmentRepository(MVCAppDbContext dbContext):base(dbContext)
+ {
+
+ }
+ }
+}
diff --git a/Demo.BLL/Repositories/EmployeeRepository.cs b/Demo.BLL/Repositories/EmployeeRepository.cs
new file mode 100644
index 0000000..419bdbb
--- /dev/null
+++ b/Demo.BLL/Repositories/EmployeeRepository.cs
@@ -0,0 +1,25 @@
+using Demo.BLL.Interfaces;
+using Demo.DAL;
+using Demo.DAL.Contexts;
+using Demo.DAL.Models;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.BLL.Repositories
+{
+ public class EmployeeRepository : GenericRepository, IEmployeeRepository
+ {
+ public EmployeeRepository(MVCAppDbContext dbContext) : base(dbContext)
+ {
+ }
+ public IQueryable GetEmployeeByaddress(string address)
+ => _dbContext.Employees.Where(E => E.Address.ToLower().Contains(address.ToLower()));
+
+ //Searching
+ public IQueryable SearchByName(string name)
+ => _dbContext.Employees.Where(E => E.Name.ToLower().Contains(name)); //search => Compare Two Names
+ }
+}
diff --git a/Demo.BLL/Repositories/GenericRepository.cs b/Demo.BLL/Repositories/GenericRepository.cs
new file mode 100644
index 0000000..8a8c61b
--- /dev/null
+++ b/Demo.BLL/Repositories/GenericRepository.cs
@@ -0,0 +1,54 @@
+using Demo.BLL.Interfaces;
+using Demo.DAL;
+using Demo.DAL.Contexts;
+using Demo.DAL.Models;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
+
+namespace Demo.BLL.Repositories
+{
+ public class GenericRepository : IGenericRepository where T : ModelBase
+ {
+ private protected readonly MVCAppDbContext _dbContext; //
+
+ public GenericRepository(MVCAppDbContext dbContext) //Ask From ClR Create
+ //Object from DbContext
+ {
+ //dbContext = /*new MVCAppDbContext();*/
+
+ _dbContext = dbContext;
+ }
+
+ //Just(Add, Update, Delete) Will change state of object
+ public void Add(T item)
+ => _dbContext.Set().Add(item); //for Example just state will change and is added
+
+ public void Update(T item)
+ => _dbContext.Set().Update(item);//Modified
+
+ public void Delete(T item)
+ => _dbContext.Set().Remove(item); //Deleted
+
+ public async Task Get(int id)
+
+ => await _dbContext.FindAsync(id);
+
+
+ //After Install package (microsoft.entityframeworkcore.proxies), We make Eager Loading to load Data of Departments at Employee
+ public async Task> GetAll()
+ {
+ if (typeof(T) == typeof(Employee))
+ return (IEnumerable) await _dbContext.Employees.Include(E => E.Department).AsNoTracking().ToListAsync();
+ else
+ return await _dbContext.Set().AsNoTracking().ToListAsync();
+ }
+
+
+
+ }
+}
diff --git a/Demo.BLL/UnitOfWork.cs b/Demo.BLL/UnitOfWork.cs
new file mode 100644
index 0000000..8475195
--- /dev/null
+++ b/Demo.BLL/UnitOfWork.cs
@@ -0,0 +1,43 @@
+using Demo.BLL.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Demo.DAL.Contexts;
+using Demo.BLL.Repositories;
+
+namespace Demo.BLL
+{
+ //UnitOfWork: Unit for each The Work With DbContext
+ //UnitOfWork Encapsulate DbContext ,PL deal with UnitOfWork and UnitOfWork deal with DbContext
+ //UnitOfWork => [Represent(deal with) Repositories + Implement Complete Method that Save Changes at DbContext + Dispose Method that dispsose connection]
+ public class UnitOfWork : IUnitOfWork
+ {
+ private readonly MVCAppDbContext _dbContext;
+
+ //Automatic properties => Compiler will get and set for Repository at Background
+ public IEmployeeRepository EmployeeRepository { get; set; }
+ public IDepartmentRepository DepartmentRepository { get; set; }
+
+
+ //CTOR, Because when create object from UnitOfWork=> Make Initialization to two Repositories
+ public UnitOfWork(MVCAppDbContext dbContext) //ASk CLR for creating Object DbContext
+ {
+ _dbContext = dbContext;
+ EmployeeRepository = new EmployeeRepository(dbContext);
+ DepartmentRepository = new DepartmentRepository(dbContext);
+ }
+ //Add Dbcontext Save Changes
+ public async Task Complete()
+ {
+ return await _dbContext.SaveChangesAsync();
+ }
+
+
+ public async ValueTask DisposeAsync()
+ {
+ await _dbContext.DisposeAsync();
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Configurations/DepartmentConfigurations.cs b/Demo.DAL/Data/Configurations/DepartmentConfigurations.cs
new file mode 100644
index 0000000..a1335fe
--- /dev/null
+++ b/Demo.DAL/Data/Configurations/DepartmentConfigurations.cs
@@ -0,0 +1,35 @@
+using Demo.DAL.Models;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.DAL.Data.Configurations
+{
+ public class DepartmentConfigurations : IEntityTypeConfiguration
+ {
+ public void Configure(EntityTypeBuilder builder)
+ {
+ //Fluent APIs for Department Entity
+ builder.Property(D => D.Id).UseIdentityColumn(10,10);
+
+ //the First 3 Lines(by default بيتنفذوا كده كده)
+ builder.HasMany(D => D.Employees)
+ .WithOne(D => D.Department)
+ .HasForeignKey(E => E.DepartmentId)
+ .OnDelete(DeleteBehavior.Cascade);
+ ;
+
+ builder.Property(D => D.Code)
+ .IsRequired(true);
+
+ builder.Property(E => E.Name)
+ .IsRequired(true)
+ .HasMaxLength(50);
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Configurations/EmployeeConfigurations.cs b/Demo.DAL/Data/Configurations/EmployeeConfigurations.cs
new file mode 100644
index 0000000..8dba446
--- /dev/null
+++ b/Demo.DAL/Data/Configurations/EmployeeConfigurations.cs
@@ -0,0 +1,26 @@
+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 Demo.DAL.Data.Configurations
+{
+ public class EmployeeConfigurations : IEntityTypeConfiguration
+ {
+ public void Configure(EntityTypeBuilder builder)
+ {
+ //fluent APIs
+
+ builder.Property(E => E.Salary)
+ .HasColumnType("decimal(18,2)");
+
+ builder.Property(E => E.Name)
+ .IsRequired(true)
+ .HasMaxLength(50);
+
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Contexts/MVCAppDbContext.cs b/Demo.DAL/Data/Contexts/MVCAppDbContext.cs
new file mode 100644
index 0000000..53755e3
--- /dev/null
+++ b/Demo.DAL/Data/Contexts/MVCAppDbContext.cs
@@ -0,0 +1,46 @@
+using Demo.DAL.Data.Configurations;
+using Demo.DAL.Models;
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Demo.DAL.Contexts
+{
+ public class MVCAppDbContext:IdentityDbContext
+ {
+
+ public MVCAppDbContext(DbContextOptionsoptions):base(options)
+ {
+
+ }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ //Fluent API
+
+ modelBuilder.ApplyConfiguration(new DepartmentConfigurations());
+
+ modelBuilder.ApplyConfiguration(new EmployeeConfigurations());
+
+ base.OnModelCreating(modelBuilder);
+ }
+ //protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
+ // =>optionsBuilder.UseSqlServer("Server = .; Database = MVCAppDb;Trusted_Connection = true;");
+
+ public DbSet Departments { get; set; }
+
+ public DbSet Employees { get; set; }
+
+ ///Identity Dbsets(4 Dbsets to Users and 3 Dbsets = 7 Dbsets) inherited from IdentityDbContext
+ ///=> Generate 7 Tables and including tables(Users + Roles + Relationship between them(UserRoles) )
+ ///public DbSet Users { get; set; }
+ ///public DbSet Roles { get; set; }
+
+
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.Designer.cs b/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.Designer.cs
new file mode 100644
index 0000000..6a92852
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.Designer.cs
@@ -0,0 +1,50 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ [Migration("20230930012622_InitialCreate")]
+ partial class InitialCreate
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.cs b/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.cs
new file mode 100644
index 0000000..1c25684
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20230930012622_InitialCreate.cs
@@ -0,0 +1,32 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Demo.DAL.Migrations
+{
+ public partial class InitialCreate : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Departments",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Code = table.Column(type: "nvarchar(max)", nullable: false),
+ Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ DateOfCreation = table.Column(type: "datetime2", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Departments", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Departments");
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.Designer.cs b/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.Designer.cs
new file mode 100644
index 0000000..59b24fd
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.Designer.cs
@@ -0,0 +1,91 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ [Migration("20231004130408_EmployeeMigration")]
+ partial class EmployeeMigration
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Address")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Age")
+ .HasColumnType("int");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("Email")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("HireDate")
+ .HasColumnType("datetime2");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Salary")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.cs b/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.cs
new file mode 100644
index 0000000..f85c461
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231004130408_EmployeeMigration.cs
@@ -0,0 +1,38 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Demo.DAL.Migrations
+{
+ public partial class EmployeeMigration : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Employees",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false),
+ Age = table.Column(type: "int", nullable: true),
+ Address = table.Column(type: "nvarchar(max)", nullable: true),
+ Salary = table.Column(type: "decimal(18,2)", nullable: false),
+ IsActive = table.Column(type: "bit", nullable: false),
+ Email = table.Column(type: "nvarchar(max)", nullable: true),
+ PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true),
+ HireDate = table.Column(type: "datetime2", nullable: false),
+ CreationDate = table.Column(type: "datetime2", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Employees", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Employees");
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.Designer.cs b/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.Designer.cs
new file mode 100644
index 0000000..e5d2bad
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.Designer.cs
@@ -0,0 +1,116 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ [Migration("20231008165329_EmployeeDepartmentRelationship")]
+ partial class EmployeeDepartmentRelationship
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Address")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Age")
+ .HasColumnType("int");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("Email")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("HireDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ISDeleted")
+ .HasColumnType("bit");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Salary")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DepartmentId");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:IdentityIncrement", 10)
+ .HasAnnotation("SqlServer:IdentitySeed", 10)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.HasOne("Demo.DAL.Models.Department", "Department")
+ .WithMany("Employees")
+ .HasForeignKey("DepartmentId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Department");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Navigation("Employees");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.cs b/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.cs
new file mode 100644
index 0000000..c8f4ba4
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231008165329_EmployeeDepartmentRelationship.cs
@@ -0,0 +1,75 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Demo.DAL.Migrations
+{
+ public partial class EmployeeDepartmentRelationship : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "DepartmentId",
+ table: "Employees",
+ type: "int",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "ISDeleted",
+ table: "Employees",
+ type: "bit",
+ nullable: false,
+ defaultValue: false);
+
+ migrationBuilder.AlterColumn(
+ name: "Id",
+ table: "Departments",
+ type: "int",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldType: "int")
+ .Annotation("SqlServer:Identity", "10, 10")
+ .OldAnnotation("SqlServer:Identity", "1, 1");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_Employees_DepartmentId",
+ table: "Employees",
+ column: "DepartmentId");
+
+ migrationBuilder.AddForeignKey(
+ name: "FK_Employees_Departments_DepartmentId",
+ table: "Employees",
+ column: "DepartmentId",
+ principalTable: "Departments",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropForeignKey(
+ name: "FK_Employees_Departments_DepartmentId",
+ table: "Employees");
+
+ migrationBuilder.DropIndex(
+ name: "IX_Employees_DepartmentId",
+ table: "Employees");
+
+ migrationBuilder.DropColumn(
+ name: "DepartmentId",
+ table: "Employees");
+
+ migrationBuilder.DropColumn(
+ name: "ISDeleted",
+ table: "Employees");
+
+ migrationBuilder.AlterColumn(
+ name: "Id",
+ table: "Departments",
+ type: "int",
+ nullable: false,
+ oldClrType: typeof(int),
+ oldType: "int")
+ .Annotation("SqlServer:Identity", "1, 1")
+ .OldAnnotation("SqlServer:Identity", "10, 10");
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.Designer.cs b/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.Designer.cs
new file mode 100644
index 0000000..051779d
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.Designer.cs
@@ -0,0 +1,119 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ [Migration("20231012153142_ImageNameColumnInEmployees")]
+ partial class ImageNameColumnInEmployees
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Address")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Age")
+ .HasColumnType("int");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("Email")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("HireDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ISDeleted")
+ .HasColumnType("bit");
+
+ b.Property("ImageName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Salary")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DepartmentId");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:IdentityIncrement", 10)
+ .HasAnnotation("SqlServer:IdentitySeed", 10)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.HasOne("Demo.DAL.Models.Department", "Department")
+ .WithMany("Employees")
+ .HasForeignKey("DepartmentId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Department");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Navigation("Employees");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.cs b/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.cs
new file mode 100644
index 0000000..928de68
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231012153142_ImageNameColumnInEmployees.cs
@@ -0,0 +1,23 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Demo.DAL.Migrations
+{
+ public partial class ImageNameColumnInEmployees : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "ImageName",
+ table: "Employees",
+ type: "nvarchar(max)",
+ nullable: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "ImageName",
+ table: "Employees");
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.Designer.cs b/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.Designer.cs
new file mode 100644
index 0000000..34ce33f
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.Designer.cs
@@ -0,0 +1,366 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ [Migration("20231013212712_SecurityModul")]
+ partial class SecurityModul
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Address")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Age")
+ .HasColumnType("int");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("Email")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("HireDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ISDeleted")
+ .HasColumnType("bit");
+
+ b.Property("ImageName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Salary")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DepartmentId");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:IdentityIncrement", 10)
+ .HasAnnotation("SqlServer:IdentitySeed", 10)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex")
+ .HasFilter("[NormalizedName] IS NOT NULL");
+
+ b.ToTable("AspNetRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RoleId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("int");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("bit");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("datetimeoffset");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("PasswordHash")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("bit");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex")
+ .HasFilter("[NormalizedUserName] IS NOT NULL");
+
+ b.ToTable("AspNetUsers");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderKey")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("RoleId")
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("UserId", "RoleId");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetUserRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("LoginProvider")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Name")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Value")
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("UserId", "LoginProvider", "Name");
+
+ b.ToTable("AspNetUserTokens");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.HasOne("Demo.DAL.Models.Department", "Department")
+ .WithMany("Employees")
+ .HasForeignKey("DepartmentId")
+ .OnDelete(DeleteBehavior.Cascade);
+
+ b.Navigation("Department");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
+ .WithMany()
+ .HasForeignKey("RoleId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
+ {
+ b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
+ .WithMany()
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Navigation("Employees");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.cs b/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.cs
new file mode 100644
index 0000000..9c98b84
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/20231013212712_SecurityModul.cs
@@ -0,0 +1,219 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Demo.DAL.Migrations
+{
+ public partial class SecurityModul : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "AspNetRoles",
+ columns: table => new
+ {
+ Id = table.Column(type: "nvarchar(450)", nullable: false),
+ Name = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ NormalizedName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetRoles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUsers",
+ columns: table => new
+ {
+ Id = table.Column(type: "nvarchar(450)", nullable: false),
+ UserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ NormalizedUserName = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ Email = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ NormalizedEmail = table.Column(type: "nvarchar(256)", maxLength: 256, nullable: true),
+ EmailConfirmed = table.Column(type: "bit", nullable: false),
+ PasswordHash = table.Column(type: "nvarchar(max)", nullable: true),
+ SecurityStamp = table.Column(type: "nvarchar(max)", nullable: true),
+ ConcurrencyStamp = table.Column(type: "nvarchar(max)", nullable: true),
+ PhoneNumber = table.Column(type: "nvarchar(max)", nullable: true),
+ PhoneNumberConfirmed = table.Column(type: "bit", nullable: false),
+ TwoFactorEnabled = table.Column(type: "bit", nullable: false),
+ LockoutEnd = table.Column(type: "datetimeoffset", nullable: true),
+ LockoutEnabled = table.Column(type: "bit", nullable: false),
+ AccessFailedCount = table.Column(type: "int", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUsers", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetRoleClaims",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ RoleId = table.Column(type: "nvarchar(450)", nullable: false),
+ ClaimType = table.Column(type: "nvarchar(max)", nullable: true),
+ ClaimValue = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
+ table.ForeignKey(
+ name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserClaims",
+ columns: table => new
+ {
+ Id = table.Column(type: "int", nullable: false)
+ .Annotation("SqlServer:Identity", "1, 1"),
+ UserId = table.Column(type: "nvarchar(450)", nullable: false),
+ ClaimType = table.Column(type: "nvarchar(max)", nullable: true),
+ ClaimValue = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
+ table.ForeignKey(
+ name: "FK_AspNetUserClaims_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserLogins",
+ columns: table => new
+ {
+ LoginProvider = table.Column(type: "nvarchar(450)", nullable: false),
+ ProviderKey = table.Column(type: "nvarchar(450)", nullable: false),
+ ProviderDisplayName = table.Column(type: "nvarchar(max)", nullable: true),
+ UserId = table.Column(type: "nvarchar(450)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
+ table.ForeignKey(
+ name: "FK_AspNetUserLogins_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserRoles",
+ columns: table => new
+ {
+ UserId = table.Column(type: "nvarchar(450)", nullable: false),
+ RoleId = table.Column(type: "nvarchar(450)", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
+ table.ForeignKey(
+ name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
+ column: x => x.RoleId,
+ principalTable: "AspNetRoles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_AspNetUserRoles_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "AspNetUserTokens",
+ columns: table => new
+ {
+ UserId = table.Column(type: "nvarchar(450)", nullable: false),
+ LoginProvider = table.Column(type: "nvarchar(450)", nullable: false),
+ Name = table.Column(type: "nvarchar(450)", nullable: false),
+ Value = table.Column(type: "nvarchar(max)", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
+ table.ForeignKey(
+ name: "FK_AspNetUserTokens_AspNetUsers_UserId",
+ column: x => x.UserId,
+ principalTable: "AspNetUsers",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetRoleClaims_RoleId",
+ table: "AspNetRoleClaims",
+ column: "RoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "RoleNameIndex",
+ table: "AspNetRoles",
+ column: "NormalizedName",
+ unique: true,
+ filter: "[NormalizedName] IS NOT NULL");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserClaims_UserId",
+ table: "AspNetUserClaims",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserLogins_UserId",
+ table: "AspNetUserLogins",
+ column: "UserId");
+
+ migrationBuilder.CreateIndex(
+ name: "IX_AspNetUserRoles_RoleId",
+ table: "AspNetUserRoles",
+ column: "RoleId");
+
+ migrationBuilder.CreateIndex(
+ name: "EmailIndex",
+ table: "AspNetUsers",
+ column: "NormalizedEmail");
+
+ migrationBuilder.CreateIndex(
+ name: "UserNameIndex",
+ table: "AspNetUsers",
+ column: "NormalizedUserName",
+ unique: true,
+ filter: "[NormalizedUserName] IS NOT NULL");
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "AspNetRoleClaims");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserClaims");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserLogins");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserRoles");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUserTokens");
+
+ migrationBuilder.DropTable(
+ name: "AspNetRoles");
+
+ migrationBuilder.DropTable(
+ name: "AspNetUsers");
+ }
+ }
+}
diff --git a/Demo.DAL/Data/Migrations/MVCAppDbContextModelSnapshot.cs b/Demo.DAL/Data/Migrations/MVCAppDbContextModelSnapshot.cs
new file mode 100644
index 0000000..8a41047
--- /dev/null
+++ b/Demo.DAL/Data/Migrations/MVCAppDbContextModelSnapshot.cs
@@ -0,0 +1,364 @@
+//
+using System;
+using Demo.DAL.Contexts;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace Demo.DAL.Migrations
+{
+ [DbContext(typeof(MVCAppDbContext))]
+ partial class MVCAppDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("Relational:MaxIdentifierLength", 128)
+ .HasAnnotation("ProductVersion", "5.0.17")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ modelBuilder.Entity("Demo.DAL.Employee", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Address")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Age")
+ .HasColumnType("int");
+
+ b.Property("CreationDate")
+ .HasColumnType("datetime2");
+
+ b.Property("DepartmentId")
+ .HasColumnType("int");
+
+ b.Property("Email")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("HireDate")
+ .HasColumnType("datetime2");
+
+ b.Property("ISDeleted")
+ .HasColumnType("bit");
+
+ b.Property("ImageName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("IsActive")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Salary")
+ .HasColumnType("decimal(18,2)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DepartmentId");
+
+ b.ToTable("Employees");
+ });
+
+ modelBuilder.Entity("Demo.DAL.Models.Department", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:IdentityIncrement", 10)
+ .HasAnnotation("SqlServer:IdentitySeed", 10)
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("DateOfCreation")
+ .HasColumnType("datetime2");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("nvarchar(50)");
+
+ b.HasKey("Id");
+
+ b.ToTable("Departments");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex")
+ .HasFilter("[NormalizedName] IS NOT NULL");
+
+ b.ToTable("AspNetRoles");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("RoleId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("AspNetRoleClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
+ {
+ b.Property("Id")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("int");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("bit");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("datetimeoffset");
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.Property("PasswordHash")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("bit");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("bit");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("nvarchar(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex")
+ .HasFilter("[NormalizedUserName] IS NOT NULL");
+
+ b.ToTable("AspNetUsers");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int")
+ .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+ b.Property("ClaimType")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ClaimValue")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserClaims");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderKey")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("AspNetUserLogins");
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property