Skip to content

Commit

Permalink
Add "getting started" documentation (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
austindrenski authored Jul 27, 2018
2 parents 3a4c675 + b00d153 commit 1a76a29
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,30 @@ title: Entity Framework 6
Npgsql has an Entity Framework 6 provider. You can use it by installing the
[EntityFramework6.Npgsql](https://www.nuget.org/packages/EntityFramework6.Npgsql/) nuget.

## Basic Configuration ##
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:

```csharp
using Npgsql;
using System.Data.Entity;

class NpgSqlConfiguration : DbConfiguration
{
public NpgSqlConfiguration()
{
var name = "Npgsql";

SetProviderFactory(providerInvariantName: name,
providerFactory: NpgsqlFactory.Instance);

SetProviderServices(providerInvariantName: name,
provider: NpgsqlServices.Instance);

SetDefaultConnectionFactory(connectionFactory: new NpgsqlConnectionFactory());
}
}
```

## Guid Support ##

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

0 comments on commit 1a76a29

Please sign in to comment.