Skip to content

Commit 5825757

Browse files
a-guy-on-the-internetmsallin
authored andcommitted
Updated README.md with more .NET Core specifics
1 parent 4cf7bfb commit 5825757

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,24 +131,34 @@ Add the following package references.
131131

132132
Add the following class.
133133
```csharp
134-
public Configuration()
135-
{
136-
SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);
137-
SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
134+
public class MyConfiguration : DbConfiguration, IDbConnectionFactory {
135+
public MyConfiguration()
136+
{
137+
SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance);
138+
SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance);
138139

139-
var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices));
140+
var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices));
140141

141-
SetProviderServices("System.Data.SQLite", providerServices);
142-
SetProviderServices("System.Data.SQLite.EF6", providerServices);
142+
SetProviderServices("System.Data.SQLite", providerServices);
143+
SetProviderServices("System.Data.SQLite.EF6", providerServices);
143144

144-
SetDefaultConnectionFactory(this);
145-
}
145+
SetDefaultConnectionFactory(this);
146+
}
146147

147-
public DbConnection CreateConnection(string connectionString)
148-
=> new SQLiteConnection(connectionString);
148+
public DbConnection CreateConnection(string connectionString)
149+
=> new SQLiteConnection(connectionString);
150+
}
149151
}
150152
```
151153

154+
Also, make sure you specify the DbConfigurationType on the DBContext class as well
155+
156+
```csharp
157+
[DbConfigurationType(typeof(MyConfiguration))]
158+
public class Context: DbContext {
159+
//... DBContext things
160+
}
161+
```
152162
## Structure
153163

154164
The code is written in an extensible way.

0 commit comments

Comments
 (0)