I am doing the simplest console project to see how to work with SQLite.
I add a System.Data.SQLite (x86 / x64) package from Nuget, which automatically pulls EF6 and Linq for it. I create the simplest code for testing.
public class Human { [Key] public Int64 ID { get; set; } public String Name { get; set; } } public class HContext : DbContext { public HContext() : base("mydb") { } public DbSet<Human> Humans { get; set; } } class Program { static void Main(string[] args) { HContext ctx = new HContext(); ctx.Humans.Add(new Human() { ID = 1, Name = "Patrik" }); ctx.SaveChanges(); } } Great, everything works and starts, but the database is created in the% UserProfile% directory. I add connectionString to the configuration file, so that the database is created in the application directory and I get an error.
<connectionStrings> <add name="mydb" connectionString="data source =.\mydb.sqlite;" providerName="System.Data.SqlClient"/> </connectionStrings> Additional information: This can be caused by the Entity Framework using an incorrect connection string. The connection string is correct.
I tried other options, the effect is the same, search engines are silent as partisans. In this regard, the question of how to register connectionString?
UPD
Also in the configuration file is System.Data.SQLite.EF6. But when I try to connect it in connectionString, I get this error.
Additional information: System.Data.SQLite.SQLiteFactory. Make sure that the ADO.NET provider is installed or registered in the application config.