C# 数据库连接对SQLite无效

C# 数据库连接对SQLite无效,c#,.net,entity-framework,C#,.net,Entity Framework,我刚刚将我的应用程序连接到SQLite,并设法在它不存在时自动创建它 但是,由于某些原因,无法创建中的表。调试时,它会在各个区域显示此异常: 系统。无效的操作异常数据库连接对无效 获取更改的数量 数据库连接对于获取最后一个插入行ID无效 这是我的appconfig <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more info

我刚刚将我的应用程序连接到SQLite,并设法在它不存在时自动创建它

但是,由于某些原因,无法创建中的表。调试时,它会在各个区域显示此异常:

系统。无效的操作异常数据库连接对无效 获取更改的数量

数据库连接对于获取最后一个插入行ID无效

这是我的appconfig

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <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.6.1" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SQLite" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6"/>
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <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" />
    </DbProviderFactories>
  </system.data>
  <connectionStrings>
    <add name="AutoPrint" connectionString="data source.\AutoPrintDb.sqlite" providerName="System.Data.SQLite" />
  </connectionStrings>
</configuration>

您是否更改了连接字符串?缺少相等的(=)



您是否更改了连接字符串?缺少相等的(=)




如果将EF6添加到末尾,则会出现以下错误::“具有固定名称的ADO.NET提供程序”System.Data.SQLite.EF6未在计算机或应用程序配置文件中注册,或者无法加载。有关详细信息,请参阅内部异常。请仅更改连接字符串,就像它仍然显示数据库连接无效一样。但是,它创建数据库文件时没有出现任何问题,但在表creationI edited my question中显示您尝试添加数据库的ExceptionID的图像时失败;数据库。请重新创建();在构造函数AutoPrintDbContext()中,如果将EF6添加到末尾,则会出现以下错误::“具有固定名称的ADO.NET提供程序”System.Data.SQLite.EF6未在计算机或应用程序配置文件中注册,或者无法加载。有关详细信息,请参阅内部异常。请仅更改连接字符串,就像它仍然显示数据库连接无效一样。但是,它创建数据库文件时没有出现任何问题,但在表creationI edited my question中显示您尝试添加数据库的ExceptionID的图像时失败;数据库。请重新创建();在构造函数AutoPrintDbContext()中
public class AutoPrintDbContext : DbContext
    {
        public AutoPrintDbContext() : base("AutoPrint")
        {
            if (!Database.Exists("AutoPrint"))
            {
                Database.SetInitializer(new DropCreateDatabaseAlways<AutoPrintDbContext>());
            }
        }
        public DbSet<Programs> Programs { get; set; }
    }
public class Programs
{
    [Key]
    public string Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public int Fields { get; set; }
    public string Filetype { get; set; }
}
<add name="AutoPrint" connectionString="data source.\AutoPrintDb.sqlite" providerName="System.Data.SQLite" />
<add name="AutoPrint" connectionString="data source=.\AutoPrintDb.sqlite" providerName="System.Data.SQLite" />