I'm trying to get to work ASP.NET.MVC4, EF6 and SQlite 3.
I have installed these packages:
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.
I have created the database and all required tables. The database files is in *\bin\
folder of the project. To confirm the SQLite database and tables exist, I have run .schema
command:
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));
I have also double checked we,config
connection string and I think VS2010 finds it (it would be error such as "CreateDatabase" is not supported by this provider or something like that). The connection string:
<connectionStrings>
<add name="WDBContext" connectionString="Data Source=|DataDirectory|wydarzenia.sqlite; Version=3" providerName="System.Data.SQLite.EF6" />
</connectionStrings>
Yet, for some reason the VS2010 says:
SQL logic error or missing database\r\nno such table: Osoba
I cannot understand why the table cannot be found! The WDBContext
class is defined as
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);
}
}
Aucun commentaire:
Enregistrer un commentaire