Skip to content

Instantly share code, notes, and snippets.

@AlexKlugZetbit
Created March 5, 2023 18:57
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save AlexKlugZetbit/d836dfc9a8d9537f501a303e4f33596f to your computer and use it in GitHub Desktop.
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
namespace PostgreSQL.Data
{
public class AppDbContext : DbContext
{
protected readonly IConfiguration Configuration;
public AppDbContext(IConfiguration configuration)
{
Configuration = configuration;
}
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
// connect to postgres with connection string from app settings
options.UseNpgsql(Configuration.GetConnectionString("WebApiDatabase"));
}
public DbSet<Employee> Employees { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment