Cucumber/Cloud/ApplicationContext.cs

31 lines
892 B
C#
Raw Normal View History

2024-10-28 02:09:55 +04:00
using Cloud.Models;
using Microsoft.EntityFrameworkCore;
namespace Cloud;
public class ApplicationContext : DbContext
{
2024-10-29 00:38:46 +04:00
public DbSet<User> Users { get; set; } = null!;
public DbSet<Farm> Farms { get; set; } = null!;
2024-10-28 02:09:55 +04:00
public ApplicationContext(DbContextOptions<ApplicationContext> options)
: base(options)
{
}
public ApplicationContext()
: base(new DbContextOptionsBuilder<ApplicationContext>()
.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");
}
}
}