File tree Expand file tree Collapse file tree 3 files changed +32
-3
lines changed
SQLite.CodeFirst.NetCore.Console Expand file tree Collapse file tree 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()
3838 System . Console . WriteLine ( "Starting Demo Application (File)" ) ;
3939 System . Console . WriteLine ( string . Empty ) ;
4040
41- using ( var context = new FootballDbContext ( " footballDb") )
41+ using ( var context = new FootballDbContext ( @"data source=.\db\ footballDb\footballDb.sqlite;foreign keys=true ") )
4242 {
4343 CreateAndSeedDatabase ( context ) ;
4444 DisplaySeededData ( context ) ;
@@ -144,4 +144,4 @@ private static void PressEnterToExit()
144144 System . Console . ReadLine ( ) ;
145145 }
146146 }
147- }
147+ }
Original file line number Diff line number Diff line change 66 </PropertyGroup >
77
88 <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" />
1011 </ItemGroup >
1112
1213 <ItemGroup >
You can’t perform that action at this time.
0 commit comments