1 | using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
---|
2 | using Microsoft.EntityFrameworkCore;
|
---|
3 | using PostgreSqlDotnetCore.Models;
|
---|
4 | using System.Xml;
|
---|
5 |
|
---|
6 | namespace PostgreSqlDotnetCore.Data
|
---|
7 | {
|
---|
8 | public class ApplicationDbContext : IdentityDbContext
|
---|
9 | {
|
---|
10 | public ApplicationDbContext() {}
|
---|
11 | public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
|
---|
12 | : base(options)
|
---|
13 | {
|
---|
14 | }
|
---|
15 |
|
---|
16 | protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
---|
17 | {
|
---|
18 | if (!optionsBuilder.IsConfigured)
|
---|
19 | {
|
---|
20 | IConfigurationRoot configuration = new ConfigurationBuilder()
|
---|
21 | .SetBasePath(Directory.GetCurrentDirectory())
|
---|
22 | .AddJsonFile("appsettings.json")
|
---|
23 | .Build();
|
---|
24 | var connectionString = configuration.GetConnectionString("DefaultConnection");
|
---|
25 | optionsBuilder.UseNpgsql(connectionString);
|
---|
26 | }
|
---|
27 | }
|
---|
28 |
|
---|
29 | protected override void OnModelCreating(ModelBuilder modelBuilder)
|
---|
30 | {
|
---|
31 | modelBuilder.HasDefaultSchema("project");
|
---|
32 | modelBuilder.Entity<UsersClass>().ToTable("users", t => t.ExcludeFromMigrations());
|
---|
33 | modelBuilder.Entity<VetCenter>().ToTable("vet_centers", t => t.ExcludeFromMigrations());
|
---|
34 | modelBuilder.Entity<BlogPostConsultation>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
35 | modelBuilder.Entity<RolesClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
36 | modelBuilder.Entity<CitiesClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
37 | modelBuilder.Entity<ProductsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
38 | modelBuilder.Entity<DiagnosticsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
39 | modelBuilder.Entity<OrdersClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
40 | modelBuilder.Entity<Pet_StatusClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
41 | modelBuilder.Entity<BreedsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
42 | modelBuilder.Entity<JobsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
43 | modelBuilder.Entity<ManufacturersClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
44 | modelBuilder.Entity<Pet_CaresClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
45 | modelBuilder.Entity<PetsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
46 | modelBuilder.Entity<ReportsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
47 | modelBuilder.Entity<TherapyClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
48 | modelBuilder.Entity<Type_Of_PetsClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
49 | modelBuilder.Entity<MedecinesClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
50 | modelBuilder.Entity<Pet_GaleryClass>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
51 | modelBuilder.Entity<BlogPostAnswers>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
52 | //modelBuilder.Entity<PetCareAllData>().Metadata.SetIsTableExcludedFromMigrations(true);
|
---|
53 | base.OnModelCreating(modelBuilder);
|
---|
54 |
|
---|
55 | // ... model definition ...
|
---|
56 | }
|
---|
57 |
|
---|
58 | public virtual DbSet<UsersClass> CustomerObj { get; set; }
|
---|
59 | public virtual DbSet<VetCenter> VetCentersObj { get; set; }
|
---|
60 | public virtual DbSet<BlogPostConsultation> BlogPostControllerObj { get; set; }
|
---|
61 | public virtual DbSet<RolesClass> RoleControllerObj { get; set; }
|
---|
62 | public virtual DbSet<CitiesClass> CitiesObj { get; set; }
|
---|
63 | public virtual DbSet<ProductsClass> ProductObj { get; set; }
|
---|
64 | public virtual DbSet<DiagnosticsClass> DiagObj { get; set; }
|
---|
65 | public virtual DbSet<BlogPostAnswers> BlogPostAnswersObj { get; set; }
|
---|
66 | public virtual DbSet<OrdersClass> OrderObj { get; set; }
|
---|
67 | public virtual DbSet<Pet_StatusClass> PetStatusObj { get; set; }
|
---|
68 | public virtual DbSet<BreedsClass> BreedsObj { get; set; }
|
---|
69 | public virtual DbSet<JobsClass> JobsObj { get; set; }
|
---|
70 | public virtual DbSet<ManufacturersClass> ManObj { get; set; }
|
---|
71 | public virtual DbSet<MedecinesClass> MedeObj { get; set; }
|
---|
72 | public virtual DbSet<Pet_CaresClass> PetCaresObj { get; set; }
|
---|
73 | //public virtual DbSet<PetCareAllData> PetCaresWithAllDataObj { get; set; }
|
---|
74 | public virtual DbSet<PetsClass> PetsObj { get; set; }
|
---|
75 | public virtual DbSet<ReportsClass> repObj { get; set; }
|
---|
76 | public virtual DbSet<TherapyClass> theraObj { get; set; }
|
---|
77 | public virtual DbSet<Type_Of_PetsClass> typeofObj { get; set; }
|
---|
78 | }
|
---|
79 | } |
---|