using Cloud.Models; using Microsoft.EntityFrameworkCore; namespace Cloud; public class ApplicationContext : DbContext { public DbSet Users { get; set; } = null!; public DbSet Farms { get; set; } = null!; public ApplicationContext(DbContextOptions options) : base(options) { } public ApplicationContext() : base(new DbContextOptionsBuilder() .UseNpgsql("Host=localhost;Port=5438;Database=main_database;Username=postgres;Password=12345") .Options) { Database.EnsureCreated(); } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { if (!optionsBuilder.IsConfigured) { optionsBuilder.UseNpgsql("Host=localhost;Port=5438;Database=main_database;Username=postgres;Password=12345"); } } }