Skip to content

Commit 1a76a29

Browse files
Add "getting started" documentation (#103)
2 parents 3a4c675 + b00d153 commit 1a76a29

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

doc/index.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,30 @@ title: Entity Framework 6
66
Npgsql has an Entity Framework 6 provider. You can use it by installing the
77
[EntityFramework6.Npgsql](https://www.nuget.org/packages/EntityFramework6.Npgsql/) nuget.
88

9+
## Basic Configuration ##
10+
To use Entity Framework with Npgsql, define a class that inherits from `DbConfiguration` in the same assembly as your class inheriting `DbContext`. Ensure that you configure provider services, a provider factory, a default connection factory as shown below:
11+
12+
```csharp
13+
using Npgsql;
14+
using System.Data.Entity;
15+
16+
class NpgSqlConfiguration : DbConfiguration
17+
{
18+
public NpgSqlConfiguration()
19+
{
20+
var name = "Npgsql";
21+
22+
SetProviderFactory(providerInvariantName: name,
23+
providerFactory: NpgsqlFactory.Instance);
24+
25+
SetProviderServices(providerInvariantName: name,
26+
provider: NpgsqlServices.Instance);
27+
28+
SetDefaultConnectionFactory(connectionFactory: new NpgsqlConnectionFactory());
29+
}
30+
}
31+
```
32+
933
## Guid Support ##
1034

1135
Npgsql EF migrations support uses `uuid_generate_v4()` function to generate guids.

0 commit comments

Comments
 (0)