Base does not exist, I do through Code First. It is necessary that the database and all tables are created automatically according to the classes of the models.
I connect System.Data.SQLite.EF6 through NuGet, I register connection configs, I create models, a context, further errors.
Configs (were created automatically, registered only connectionStrings):
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> </configSections> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> <entityFramework> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> <parameters> <parameter value="v11.0" /> </parameters> </defaultConnectionFactory> <providers> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" /> </providers> </entityFramework> <system.data> <DbProviderFactories> <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" /> </DbProviderFactories> </system.data> <connectionStrings> <add name="DbConnection" connectionString="Data Source=C:\test.db;Version=3" providerName="System.Data.SQLite.EF6" /> </connectionStrings> </configuration> Context:
public class ProjectContext : DbContext { public ProjectContext() : base("DbConnection") { } public DbSet<Account> Accounts { get; set; } } As a result, throws an exception on the line public ProjectContext (): base ("DbConnection")
Unhandled exception of type "System.InvalidOperationException" in mscorlib.dll
More information: The Entity Framework provider type 'System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6' registered with the application system 'System.Data.SQLite.EF6 'could not be loaded. Make sure that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Tell me, please, where is it?
UPD: Added System.Data.SQLite with NuGet'a, the context is created normally. However, it now throws an exception when trying to add a model object to the DbSet context:
No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SQLite'.