diff --git a/doc/index.md b/doc/index.md index d3c5539ba..adce1a514 100644 --- a/doc/index.md +++ b/doc/index.md @@ -14,20 +14,33 @@ Following is an example (new-style) csproj using Npgsql EF Core: Exe - netcoreapp1.1 + netcoreapp2.0 - - - - + + - + ``` +## Using the Npgsql provider + + public class BlogContext : DbContext + { + // When used with ASP.net core, add these lines to Startup.cs + // var connectionString = Configuration.GetConnectionString("BlogContext"); + // services.AddEntityFrameworkNpgsql().AddDbContext(options => options.UseNpgsql(connectionString)); + // and add this to appSettings.json + // "ConnectionStrings": { "BlogContext": "Server=localhost;Database=blog" } + + public BlogContext(DbContextOptions options) : base(options) { } + + public DbSet BlogPosts { get; set; } + } + ## Using an Existing Database (Database-First) The Npgsql EF Core provider also supports reverse-engineering a code model from an existing PostgreSQL database ("database-first"). To do so, add a dependency on Npgsql.EntityFrameworkCore.PostgreSQL.Design. Then, execute the following if you're using dotnet cli: