Skip to content

Instantly share code, notes, and snippets.

@teyc
Created April 25, 2021 06:51
Show Gist options
  • Save teyc/3ef06e60229c80c69b580d9859805292 to your computer and use it in GitHub Desktop.
Save teyc/3ef06e60229c80c69b580d9859805292 to your computer and use it in GitHub Desktop.
Prototyping web applications
// <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.3" />
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql("Host=my_host;Database=my_db;Username=my_user;Password=my_pw");
}
// Database first
// dotnet ef dbcontext scaffold "Host=my_host;Database=my_db;Username=my_user;Password=my_pw" Npgsql.EntityFrameworkCore.PostgreSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment