source: PostgreSqlDotnetCore/Data/ApplicationDbContext.cs@ 2aea0fd

main
Last change on this file since 2aea0fd was 2aea0fd, checked in by ElenaMoskova <elena.moskova99@…>, 2 months ago

init commit Elena

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[2aea0fd]1using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
2using Microsoft.EntityFrameworkCore;
3using PostgreSqlDotnetCore.Models;
4using System.Xml;
5
6namespace 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}
Note: See TracBrowser for help on using the repository browser.