@@ -131,24 +131,34 @@ Add the following package references.
131131
132132Add 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
154164The code is written in an extensible way.
0 commit comments