using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; using PostgreSqlDotnetCore.Models; using System.Xml; namespace PostgreSqlDotnetCore.Data { public class ApplicationDbContext : IdentityDbContext { public ApplicationDbContext() {} public ApplicationDbContext(DbContextOptions options) : base(options) { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") .Build(); var connectionString = configuration.GetConnectionString("DefaultConnection"); optionsBuilder.UseNpgsql(connectionString); } } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema("project"); modelBuilder.Entity().ToTable("users", t => t.ExcludeFromMigrations()); modelBuilder.Entity().ToTable("vet_centers", t => t.ExcludeFromMigrations()); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); //modelBuilder.Entity().Metadata.SetIsTableExcludedFromMigrations(true); // додадени следните два реда на 28.08 // modelBuilder.Entity().HasNoKey(); // Дефинирајте дека VIEW-от нема примарен клуч // modelBuilder.Entity().ToView("vet_centers_with_city"); // Поставете го името на VIEW-от modelBuilder.Entity().HasNoKey().ToView("vet_centers_with_city"); base.OnModelCreating(modelBuilder); // Configure the relationship between VetCenter and CitiesClass // ... model definition ... } public virtual DbSet CustomerObj { get; set; } public virtual DbSet VetCentersObj { get; set; } // додадено на 28.08 public virtual DbSet VetCentersWithCity { get; set; } public virtual DbSet BlogPostControllerObj { get; set; } public virtual DbSet RoleControllerObj { get; set; } public virtual DbSet CitiesObj { get; set; } public virtual DbSet ProductObj { get; set; } public virtual DbSet DiagObj { get; set; } public virtual DbSet BlogPostAnswersObj { get; set; } public virtual DbSet OrderObj { get; set; } public virtual DbSet PetStatusObj { get; set; } public virtual DbSet BreedsObj { get; set; } public virtual DbSet JobsObj { get; set; } public virtual DbSet ManObj { get; set; } public virtual DbSet MedeObj { get; set; } public virtual DbSet PetCaresObj { get; set; } //public virtual DbSet PetCaresWithAllDataObj { get; set; } public virtual DbSet PetsObj { get; set; } public virtual DbSet repObj { get; set; } public virtual DbSet theraObj { get; set; } public virtual DbSet typeofObj { get; set; } public virtual DbSet PetDetailsProcedureObj { get; set; } //public virtual DbSet AddVetCenter { get; set; } } }