Skip to content

Commit 3e73ace

Browse files
teycroji
authored andcommitted
Update documentation to 2.0.0 (#245)
* Update documentation to 2.0.0 and give an example of Npgsql connection string for those who may be unsure * Remove Design package as it is folded in
1 parent a3603a6 commit 3e73ace

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

doc/index.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,33 @@ Following is an example (new-style) csproj using Npgsql EF Core:
1414
<Project Sdk="Microsoft.NET.Sdk">
1515
<PropertyGroup>
1616
<OutputType>Exe</OutputType>
17-
<TargetFramework>netcoreapp1.1</TargetFramework>
17+
<TargetFramework>netcoreapp2.0</TargetFramework>
1818
</PropertyGroup>
1919
<ItemGroup>
20-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="1.1.0" />
21-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" PrivateAssets="All" />
22-
<!-- For scaffolding support -->
23-
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" PrivateAssets="All" />
20+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
21+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
2422
</ItemGroup>
2523
<ItemGroup>
26-
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.1" />
24+
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
2725
</ItemGroup>
2826
</Project>
2927
```
3028

29+
## Using the Npgsql provider
30+
31+
public class BlogContext : DbContext
32+
{
33+
// When used with ASP.net core, add these lines to Startup.cs
34+
// var connectionString = Configuration.GetConnectionString("BlogContext");
35+
// services.AddEntityFrameworkNpgsql().AddDbContext<BlogContext>(options => options.UseNpgsql(connectionString));
36+
// and add this to appSettings.json
37+
// "ConnectionStrings": { "BlogContext": "Server=localhost;Database=blog" }
38+
39+
public BlogContext(DbContextOptions<BlogContext> options) : base(options) { }
40+
41+
public DbSet<BlogPost> BlogPosts { get; set; }
42+
}
43+
3144
## Using an Existing Database (Database-First)
3245

3346
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:

0 commit comments

Comments
 (0)