109 lines
3.9 KiB
C#
109 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Church.Net.Entity;
|
|
using Microsoft.AspNetCore.Identity;
|
|
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace Church.Net.DAL.EF
|
|
{
|
|
//public class ChurchNetContext:DbContext
|
|
//{
|
|
// public ChurchNetContext():base("entityFramework")
|
|
// {
|
|
|
|
// }
|
|
|
|
// public ChurchNetContext(string connString):base(connString)
|
|
// {
|
|
|
|
// }
|
|
// //public DbSet<PastoralDomain> PastoralDomains { get; set; }
|
|
// //public DbSet<FamilyMember> FamilyMembers { get; set; }
|
|
// //public DbSet<Career> Careers { get; set; }
|
|
// public DbSet<NewVisitor> NewVisitors { get; set; }
|
|
// //public DbSet<Religion> Religions { get; set; }
|
|
|
|
|
|
// protected override void OnModelCreating(DbModelBuilder modelBuilder)
|
|
// {
|
|
// modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
|
|
// }
|
|
//}
|
|
|
|
|
|
public class ChurchNetContext : DbContext
|
|
{
|
|
private static bool _created = true;
|
|
public ChurchNetContext(DbContextOptions<ChurchNetContext> options) :base(options)
|
|
{
|
|
|
|
}
|
|
//public ChurchNetContext()
|
|
//{
|
|
// var folder = Environment.SpecialFolder.LocalApplicationData;
|
|
// var path = Environment.GetFolderPath(folder);
|
|
// DbPath = System.IO.Path.Join(path, "ChurchNet.db");
|
|
// DbPath = @"C:\WebSites\ChurchNetAPI\App_Data\ChurchNet.db";
|
|
// if (!_created)
|
|
// {
|
|
// _created = true;
|
|
// Database.EnsureDeleted();
|
|
// Database.EnsureCreated();
|
|
// }
|
|
//}
|
|
//public ChurchNetContext(string connectionString)
|
|
//{
|
|
// var folder = Environment.SpecialFolder.LocalApplicationData;
|
|
// var path = Environment.GetFolderPath(folder);
|
|
// DbPath = System.IO.Path.Join(path, "ChurchNet.db");
|
|
// DbPath = @"C:\WebSites\ChurchNetAPI\App_Data\ChurchNet.db";
|
|
// if (!_created)
|
|
// {
|
|
// _created = true;
|
|
// Database.EnsureDeleted();
|
|
// Database.EnsureCreated();
|
|
// }
|
|
//}
|
|
//public DbSet<PastoralDomain> PastoralDomains { get; set; }
|
|
//public DbSet<FamilyMember> FamilyMembers { get; set; }
|
|
//public DbSet<Career> Careers { get; set; }
|
|
|
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
|
{
|
|
//modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
|
|
|
|
}
|
|
|
|
public string DbPath { get; }
|
|
//protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
// => options.UseSqlite($"Data Source={DbPath}");
|
|
|
|
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
|
// => optionsBuilder.UseNpgsql("Host=my_host;Database=my_db;Username=my_user;Password=my_pw");
|
|
//public System.Data.Entity.DbSet<Church.Net.Entity.FamilyMember> FamilyMembers { get; set; }
|
|
|
|
public DbSet<NewVisitor> NewVisitors { get; set; }
|
|
public DbSet<Religion> Religions { get; set; }
|
|
|
|
public DbSet<PastoralDomainMembers> PastoralDomainMembers { get; set; }
|
|
|
|
public DbSet<Career> Careers { get; set; }
|
|
|
|
public DbSet<PastoralDomain> PastoralDomains { get; set; }
|
|
public DbSet<WhoIsSpy> WhoIsSpy { get; set; }
|
|
public DbSet<Vocabulary> Vocabulary { get; set; }
|
|
public DbSet<HappinessGroup> HappinessGroups { get; set; }
|
|
public DbSet<HappinessBEST> HappinessBESTs { get; set; }
|
|
public DbSet<HappinessWeek> HappinessWeeks { get; set; }
|
|
public DbSet<CellGroupRoutineEvent> CellGroupRoutineEvents { get; set; }
|
|
public DbSet<CellGroupRoutineEventAttendee> CellGroupRoutineEventAttendees { get; set; }
|
|
|
|
|
|
|
|
}
|
|
}
|