????3. ????????3
???????????????????????????????????????μ??????
????Unable to determine the provider name for provider factory of type 'System.Data.SQLite.SQLiteFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
????Sqlite????Щ???????NuGet??????????NuGetò????а????????????????????????????????
????????????????????????????????????
<system.data>
<DbProviderFactories>
<span style="color: #ff0000;"><remove invariant="System.Data.SQLite" />
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory?? System.Data.SQLite"/></span>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory?? System.Data.SQLite.EF6" />
<remove invariant="System.Data.SqlServerCe.4.0" />
<add name="Microsoft SQL Server Compact Data Provider 4.0" invariant="System.Data.SqlServerCe.4.0" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory?? System.Data.SqlServerCe?? Version=4.0.0.0?? Culture=neutral?? PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlCeConnectionFactory?? EntityFramework">
<parameters>
<parameter value="System.Data.SqlServerCe.4.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<span style="color: #ff0000;"><provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices?? System.Data.SQLite.EF6" /></span>
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices?? System.Data.SQLite.EF6" />
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices?? EntityFramework.SqlServer" />
<provider invariantName="System.Data.SqlServerCe.4.0" type="System.Data.Entity.SqlServerCompact.SqlCeProviderServices?? EntityFramework.SqlServerCompact" />
</providers>
</entityFramework><br>
????4. ?????????Code First??????System.Data.SQLite.EF6?????????????????????????????????????????????????????????????????????Sqlite??Migration??EF Provider??
????OK???????????????????????
????5. ????DataDirectory
???????Sqlite?????????????????д???
????<add name="BloggingContext_SQLite" connectionString="Data Source=|DataDirectory|Blogging_SQLite.db" providerName="System.Data.SQLite.EF6"/>
?????????????????????????????????????棬????????

?????????????????????DataDirectory?????????
????private static void SetDataDir()
????{
????DirectoryInfo baseDir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
????string data_dir = baseDir.FullName;
????if ((baseDir.Name.ToLower() == "debug" || baseDir.Name.ToLower() == "release")
????&& (baseDir.Parent.Name.ToLower() == "bin"))
????{
????data_dir = Path.Combine(baseDir.Parent.Parent.FullName?? "App_Data");
????}
????AppDomain.CurrentDomain.SetData("DataDirectory"?? data_dir);
????}
?????????????????á?