小编Art*_*ump的帖子

ASP.NET 5,EF 7和SQLite - SQLite错误1:'没有这样的表:博客'

我遵循了关于Entity Framework 7的ASP.NET 5入门指南,我用Sqlite替换了MicrosoftSqlServer,代码的唯一区别在于Startup.cs:

services.AddEntityFramework()
    .AddSqlite()
    .AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=db.db"));
Run Code Online (Sandbox Code Playgroud)

当我运行网站并导航到/ Blogs时,我收到一个错误:

Microsoft.Data.Sqlite.SqliteException是由用户代码未处理的
错误码= -2147467259的HResult = -2147467259消息= SQLite的错误1: '没有这样的表:博客'源= Microsoft.Data.Sqlite
SqliteErrorCode = 1个堆栈跟踪:在Microsoft.Data. Sqlite.Interop.MarshalEx.ThrowExceptionForRC(RC的Int32,Sqlite3Handle DB)在Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(的CommandBehavior行为)在Microsoft.Data.Sqlite.SqliteCommand.ExecuteDbDataReader(的CommandBehavior行为)在System.Data.Common.DbCommand .ExecuteReader()在Microsoft.Data.Entity.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()在System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()在System.Linq.Enumerable.d__1`2.MoveNext()在System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()在Microsoft.Data.Entity.Query.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()在System.Collections.Generic.List`1..ctor(IEnumerable` 1个集合)在System.Linq.Enumerable.ToList [TSo urce]在d(IEnumerable`1源)在EFGetStarted.AspNet5.Controllers.BlogsController.Index():\阿瑟\文件\视觉工作室2015 \项目\ EFGetStarted.AspNet5\SRC\EFGetStarted.AspNet5 \控制器\ BlogsController.cs: regel 18 InnerException:

我理解这就好像没有名为'Blog'的表,但是当我在DB Browser for SQLite中打开.db文件时,实际上有一个名为'Blog'的表:

DB Browser for SQLite的屏幕截图显示了一个名为'Blog'的表格

SQLite是否需要对代码进行其他更改,或者这是Entity Framework的SQLite连接器中的错误?

asp.net sqlite entity-framework entity-framework-core asp.net-core

13
推荐指数
5
解决办法
1万
查看次数