Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET.MVC、EF 6和SQLite 3-在数据库中查找表时出错_C#_Asp.net Mvc_Entity Framework_Sqlite - Fatal编程技术网

C# ASP.NET.MVC、EF 6和SQLite 3-在数据库中查找表时出错

C# ASP.NET.MVC、EF 6和SQLite 3-在数据库中查找表时出错,c#,asp.net-mvc,entity-framework,sqlite,C#,Asp.net Mvc,Entity Framework,Sqlite,我正在尝试使用ASP.NET.MVC4、EF6和SQlite 3 我已安装以下软件包: EntityFramework 6.1.3 Entity Framework is Microsoft's recommended data access technology for new... Microsoft.AspNet.Mvc 4.0.20710.0 This package contains th

我正在尝试使用ASP.NET.MVC4、EF6和SQlite 3

我已安装以下软件包:

EntityFramework                6.1.3                Entity Framework is Microsoft's recommended data access technology for new...
Microsoft.AspNet.Mvc           4.0.20710.0          This package contains the runtime assemblies for ASP.NET MVC. ASP.NET MVC ...
Microsoft.AspNet.Razor         2.0.20710.0          This package contains the runtime assemblies for ASP.NET Web Pages. ASP.NE...
Microsoft.AspNet.WebApi        4.0.20710.0          This package contains everything you need to host ASP.NET Web API on IIS. ...
Microsoft.AspNet.WebApi.Client 4.0.20710.0          This package adds support for formatting and content negotiation to System...
Microsoft.AspNet.WebApi.Core   4.0.20710.0          This package contains the core runtime assemblies for ASP.NET Web API. Thi...
Microsoft.AspNet.WebApi.Web... 4.0.20710.0          This package contains everything you need to host ASP.NET Web API on IIS. ...
Microsoft.AspNet.WebPages      2.0.20710.0          This package contains core runtime assemblies shared between ASP.NET MVC a...
Microsoft.Net.Http             2.0.20710.0          This package provides a programming interface for modern HTTP applications...
Microsoft.Web.Infrastructure   1.0.0.0              This package contains the Microsoft.Web.Infrastructure assembly that lets ...
Newtonsoft.Json                4.5.6                Json.NET is a popular high-performance JSON framework for .NET               
System.Data.SQLite             1.0.98.1             The official SQLite database engine for both x86 and x64 along with the AD...
System.Data.SQLite.Core        1.0.98.1             The official SQLite database engine for both x86 and x64 along with the AD...
System.Data.SQLite.EF6         1.0.98.1             Support for Entity Framework 6 using System.Data.SQLite.                     
System.Data.SQLite.Linq        1.0.98.1             Support for LINQ using System.Data.SQLite.                                   
我已经创建了数据库和所有必需的表。数据库文件位于项目的
*\bin\
文件夹中。为了确认SQLite数据库和表是否存在,我运行了
.schema
命令:

CREATE TABLE Wydarzenie(WydarzenieID INTEGER PRIMARY KEY AUTOINCREMENT, NazwaWydarzenia TEXT NOT NULL, Informacja TEXT);
CREATE TABLE Osoba(OsobaID INTEGER PRIMARY KEY AUTOINCREMENT, Imie TEXT NOT NULL, Nazwisko TEXT, Informacja TEXT);
CREATE TABLE GrupaWydarzenia(OsobaID INTEGER NOT NULL, WydarzenieID INTEGER NOT NULL, Przypomnienie INTEGER NOT NULL, PRIMARY KEY (OsobaID, WydarzenieID), FOREIGN KEY(OsobaID) REFERENCES Osoby(OsobaID), FOREIGN KEY(WydarzenieID) REFERENCES Wydarzenia(WydarzenieID));
我还仔细检查了
we,config
连接字符串,我认为VS2010找到了它(这可能是一个错误,例如此提供程序不支持“CreateDatabase”之类的内容)。连接字符串:

<connectionStrings>
    <add name="WDBContext" connectionString="Data Source=|DataDirectory|wydarzenia.sqlite; Version=3" providerName="System.Data.SQLite.EF6" />
</connectionStrings>

我非常确定
bin
目录中的数据库文件在构建时被覆盖。将数据库放在应用程序的一个目录中(将东西放在
bin
中不是你自己的方式),类似于
App\u Data
,然后在那里进行修改。我发现它在
bin
中既没有被覆盖,也没有被触及。正如您正确指出的,它是在
App_Data
中创建的,但一旦创建,它就不会在那里被覆盖。谢谢。我很确定你在
bin
目录下的数据库文件在构建时被覆盖了。将数据库放在应用程序的一个目录中(将东西放在
bin
中不是你自己的方式),类似于
App\u Data
,然后在那里进行修改。我发现它在
bin
中既没有被覆盖,也没有被触及。正如您正确指出的,它是在
App_Data
中创建的,但一旦创建,它就不会在那里被覆盖。谢谢
public class WDBContext : DbContext
{
    public DbSet<Wydarzenie> Wydarzenia { get; set; }
    public DbSet<Osoba> Osoby { get; set; }
    public DbSet<GrupaWydarzenia> GrupyWydarzen { get; set; }

    public WDBContext()
        : base("WDBContext")
    {
    }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();

        modelBuilder.Configurations.Add(new WydarzenieEntityConfiguration());
        modelBuilder.Configurations.Add(new OsobaEntityConfiguration());
        modelBuilder.Configurations.Add(new GrupaWydarzeniaEntityConfiguration());

        base.OnModelCreating(modelBuilder);
    }
}