Cucumber/Cloud/ApplicationContext.cs
2024-10-28 02:09:55 +04:00

30 lines
831 B
C#

using Cloud.Models;
using Microsoft.EntityFrameworkCore;
namespace Cloud;
public class ApplicationContext : DbContext
{
public DbSet<User> Users { get; set; }
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");
}
}
}