File tree 3 files changed +32
-3
lines changed
SQLite.CodeFirst.NetCore.Console
3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change
1
+ using System . Data . Common ;
2
+ using System . Data . Entity ;
3
+ using System . Data . Entity . Core . Common ;
4
+ using System . Data . Entity . Infrastructure ;
5
+ using System . Data . SQLite ;
6
+ using System . Data . SQLite . EF6 ;
7
+
8
+ namespace SQLite . CodeFirst . NetCore . Console
9
+ {
10
+ public class Configuration : DbConfiguration , IDbConnectionFactory
11
+ {
12
+ public Configuration ( )
13
+ {
14
+ SetProviderFactory ( "System.Data.SQLite" , SQLiteFactory . Instance ) ;
15
+ SetProviderFactory ( "System.Data.SQLite.EF6" , SQLiteProviderFactory . Instance ) ;
16
+
17
+ var providerServices = ( DbProviderServices ) SQLiteProviderFactory . Instance . GetService ( typeof ( DbProviderServices ) ) ;
18
+
19
+ SetProviderServices ( "System.Data.SQLite" , providerServices ) ;
20
+ SetProviderServices ( "System.Data.SQLite.EF6" , providerServices ) ;
21
+
22
+ SetDefaultConnectionFactory ( this ) ;
23
+ }
24
+
25
+ public DbConnection CreateConnection ( string connectionString )
26
+ => new SQLiteConnection ( connectionString ) ;
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ private static void StartDemoUseFile()
38
38
System . Console . WriteLine ( "Starting Demo Application (File)" ) ;
39
39
System . Console . WriteLine ( string . Empty ) ;
40
40
41
- using ( var context = new FootballDbContext ( " footballDb") )
41
+ using ( var context = new FootballDbContext ( @"data source=.\db\ footballDb\footballDb.sqlite;foreign keys=true ") )
42
42
{
43
43
CreateAndSeedDatabase ( context ) ;
44
44
DisplaySeededData ( context ) ;
@@ -144,4 +144,4 @@ private static void PressEnterToExit()
144
144
System . Console . ReadLine ( ) ;
145
145
}
146
146
}
147
- }
147
+ }
Original file line number Diff line number Diff line change 6
6
</PropertyGroup >
7
7
8
8
<ItemGroup >
9
- <PackageReference Include =" System.Data.SQLite" Version =" 1.0.112" />
9
+ <PackageReference Include =" System.Data.SQLite" Version =" 1.0.112.2" />
10
+ <PackageReference Include =" System.Data.SQLite.EF6" Version =" 1.0.112.2" />
10
11
</ItemGroup >
11
12
12
13
<ItemGroup >
You can’t perform that action at this time.
0 commit comments