我遵循了关于Entity Framework7的Getting Started on ASP.NET 5指南,并用Sqlite替换了MicrosoftSqlServer,代码中唯一的区别是Startup.cs:
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<BloggingContext>(options => options.UseSqlite("Filename=db.db"));
当我运行网站并导航到/blog时,我会收到一个错误:
用户代码未处理Microsoft.Data.Sqlite.SqliteException
错误代码=-2147467259 HResult=-2147467259消息=SQLite错误1: ‘没有这样的表:博客’Source=Microsoft.Data.Sqlite
SqliteErrorCode=1 StackTrace: 在Microsoft.Data.Sqlite.Interop.MarshalEx.ThrowExceptionForRC(Int32 RC, Sqlite3句柄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[TSource](IEnumerable`1源) 位于d:\arthur\Documents\visual studio中的EFGetStarted.AspNet5.Controllers.BlogsController.Index() 2015\Projects\EFGetStarted.AspNet5\src\EFGetStarted.AspNet5\Controllers\BlogsController.cs:regel 18内部异常:
我理解这一点就好像没有叫做"Blog"的表,但当我打开.db文件在SQLite的db浏览器中,实际上有一个名为"Blog"的表:
SQLite是否需要在代码中进行其他更改,或者这是实体框架SQLite连接器中的错误?