source: PostgreSqlDotnetCore/Data/ApplicationDbContext.cs@ e9bb9d1

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

Use of views

  1. Use of views in VetCenters.
  2. Ability to provide a response to a given response.
  • Property mode set to 100644
File size: 5.5 KB
Line 
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
53 modelBuilder.Entity<PetDetailsProcedure>().Metadata.SetIsTableExcludedFromMigrations(true);
54 //modelBuilder.Entity<PetCareAllData>().Metadata.SetIsTableExcludedFromMigrations(true);
55
56 // додадени следните два реда на 28.08
57 // modelBuilder.Entity<VetCenterWithCity>().HasNoKey(); // Дефинирајте дека VIEW-от нема примарен клуч
58 // modelBuilder.Entity<VetCenterWithCity>().ToView("vet_centers_with_city"); // Поставете го името на VIEW-от
59 modelBuilder.Entity<VetCenterWithCity>().HasNoKey().ToView("vet_centers_with_city");
60 base.OnModelCreating(modelBuilder);
61
62 // Configure the relationship between VetCenter and CitiesClass
63
64
65
66 // ... model definition ...
67 }
68
69 public virtual DbSet<UsersClass> CustomerObj { get; set; }
70 public virtual DbSet<VetCenter> VetCentersObj { get; set; }
71
72 // додадено на 28.08
73 public virtual DbSet<VetCenterWithCity> VetCentersWithCity { get; set; }
74
75 public virtual DbSet<BlogPostConsultation> BlogPostControllerObj { get; set; }
76 public virtual DbSet<RolesClass> RoleControllerObj { get; set; }
77 public virtual DbSet<CitiesClass> CitiesObj { get; set; }
78 public virtual DbSet<ProductsClass> ProductObj { get; set; }
79 public virtual DbSet<DiagnosticsClass> DiagObj { get; set; }
80 public virtual DbSet<BlogPostAnswers> BlogPostAnswersObj { get; set; }
81 public virtual DbSet<OrdersClass> OrderObj { get; set; }
82 public virtual DbSet<Pet_StatusClass> PetStatusObj { get; set; }
83 public virtual DbSet<BreedsClass> BreedsObj { get; set; }
84 public virtual DbSet<JobsClass> JobsObj { get; set; }
85 public virtual DbSet<ManufacturersClass> ManObj { get; set; }
86 public virtual DbSet<MedecinesClass> MedeObj { get; set; }
87 public virtual DbSet<Pet_CaresClass> PetCaresObj { get; set; }
88 //public virtual DbSet<PetCareAllData> PetCaresWithAllDataObj { get; set; }
89 public virtual DbSet<PetsClass> PetsObj { get; set; }
90 public virtual DbSet<ReportsClass> repObj { get; set; }
91 public virtual DbSet<TherapyClass> theraObj { get; set; }
92 public virtual DbSet<Type_Of_PetsClass> typeofObj { get; set; }
93
94 public virtual DbSet<PetDetailsProcedure> PetDetailsProcedureObj { get; set; }
95
96 //public virtual DbSet<PetDetailsProcedure> AddVetCenter { get; set; }
97
98 }
99}
Note: See TracBrowser for help on using the repository browser.