using Microsoft.EntityFrameworkCore; using System; namespace DevExpress.DevAV { public class DevAVDb : DbContext { public DevAVDb(string connectionStringOrName) { connectionString = connectionStringOrName; } string connectionString = @"Data Source=C:\Work\OutlookWpf\Data\devav.sqlite3"; public DevAVDb() : base() { } protected override void OnConfiguring(DbContextOptionsBuilder optionbuilder) { optionbuilder.UseLazyLoadingProxies().UseSqlite(connectionString); } public DbSet Customers { get; set; } public DbSet Employees { get; set; } public DbSet Products { get; set; } public DbSet Tasks { get; set; } public DbSet Crests { get; set; } public DbSet Communications { get; set; } public DbSet CustomerStores { get; set; } public DbSet Orders { get; set; } public DbSet OrderItems { get; set; } public DbSet Probations { get; set; } public DbSet ProductCatalogs { get; set; } public DbSet ProductImages { get; set; } public DbSet Quotes { get; set; } public DbSet QuoteItems { get; set; } public DbSet States { get; set; } public DbSet CustomerEmployees { get; set; } public DbSet Evaluations { get; set; } public DbSet Pictures { get; set; } public DbSet AttachedFiles { get; set; } public DbSet Version { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity() .HasOne(x => x.Picture) .WithMany(x => x.Employees); modelBuilder.Entity() .HasOne(x => x.ProbationReason) .WithMany(x => x.Employees) .HasForeignKey(x => x.ProbationReason_Id); modelBuilder.Entity() .HasOne(x => x.CreatedBy) .WithMany(x => x.EvaluationsCreatedBy); modelBuilder.Entity() .HasOne(x => x.CustomerStore) .WithMany(x => x.CustomerEmployees); modelBuilder.Entity() .HasOne(x => x.Picture) .WithMany(x => x.CustomerEmployees); modelBuilder.Entity() .HasOne(x => x.Crest) .WithMany(x => x.CustomerStores); modelBuilder.Entity() .HasOne(x => x.Employee) .WithMany(x => x.Orders); modelBuilder.Entity() .HasOne(x => x.Store) .WithMany(x => x.Orders); modelBuilder.Entity() .HasOne(x => x.Engineer) .WithMany(x => x.Products); modelBuilder.Entity() .HasOne(x => x.PrimaryImage) .WithMany(x => x.Products); modelBuilder.Entity() .HasOne(x => x.Support) .WithMany(x => x.SupportedProducts); modelBuilder.Entity() .HasOne(x => x.Picture) .WithMany(x => x.ProductImages); modelBuilder.Entity() .HasOne(x => x.CustomerStore) .WithMany(x => x.Quotes); modelBuilder.Entity() .HasOne(x => x.Employee) .WithMany(x => x.Quotes); modelBuilder.Entity() .HasOne(x => x.Product) .WithMany(x => x.QuoteItems); modelBuilder.Entity() .HasOne(x => x.CustomerEmployee) .WithMany(x => x.CustomerCommunications); modelBuilder.Entity() .HasOne(x => x.Employee) .WithMany(x => x.Employees); modelBuilder.Entity() .Ignore(x => x.AssignedEmployeeTasks); modelBuilder.Entity() .Ignore(x => x.AssignedEmployees); modelBuilder.Entity() .Ignore(x => x.AssignedTasks); modelBuilder.Entity() .Ignore(x => x.OwnedTasks); modelBuilder.Entity() .Ignore(x => x.Employees); } } public class DatabaseVersion : DatabaseObject { public DateTime Date { get; set; } } }