| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.Configuration;
- using GreenTree.Maschinenbestellungen.Core.Domain.Rights;
- using GreenTree.Maschinenbestellungen.Domain.Model.Rights;
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Text;
- using GreenTree.Maschinenbestellungen.Core.Domain.Business;
- using GreenTree.Maschinenbestellungen.Domain.Model.Business;
- namespace GreenTree.Maschinenbestellungen.Domain.Model
- {
- public class OrderDbContext : DbContext
- {
- #region Tables
- /// <summary>
- /// Users table
- /// </summary>
- public DbSet<User> Users { get; set; }
- /// <summary>
- /// Policies table
- /// </summary>
- public DbSet<Policy> Policies { get; set; }
- /// <summary>
- /// UserPolicies table
- /// </summary>
- public DbSet<UserPolicy> UserPolicies { get; set; }
- #endregion
- #region Constructor
- /// <summary>
- /// Initializes a new instance of the ERPDbContext class
- /// </summary>
- /// <param name="options">Database context options.</param>
- public OrderDbContext(DbContextOptions options) : base(options)
- {
- }
- #endregion
- #region Overrides
- /// <summary>
- /// Model creation override method to initialize the necessary model mappings
- /// </summary>
- /// <param name="modelBuilder">The model builder.</param>
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.ApplyConfiguration(new UserMapping());
- modelBuilder.ApplyConfiguration(new PolicyMapping());
- modelBuilder.ApplyConfiguration(new UserPolicyMapping());
- }
- #endregion
- #region Data
- /// <summary>
- /// Create seed data for the model database
- /// </summary>
- /// <typeparam name="T">The entity type gaining the seed data.</typeparam>
- /// <param name="modelBuilder">The basted model builder.</param>
- /// <param name="data">The seeded data.</param>
- private void CreateSeedDate<T>(ModelBuilder modelBuilder, params T[] data)
- {
- modelBuilder.Entity(typeof(T))
- .HasData(data);
- }
- #endregion
- }
- }
|