ASP.NET 5:kpm无法找到EntityFramework.Sqlite和Microsoft.Data.Sqlite包

时间:2016-02-26 12:48:57

标签: asp.net .net entity-framework sqlite kpm

我试图在ASP.NET 5网站中使用SQLite,但我遇到了EntityFramework.Sqlite和Microsoft.Data.Sqlite软件包的问题。 kpm restore命令给了我:

C:\Users\jerom\Documents\Visual Studio 2015\Projects\TongyiFapiao\src\TongyiFapiao>kpm restore
Restoring packages for C:\Users\jerom\Documents\Visual Studio 2015\Projects\TongyiFapiao\src\TongyiFapiao\project.json
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite'.
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite'.
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite' 1228ms
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite' 1262ms
The XML file C:\Users\jerom\AppData\Local\kpm\cache\ca78217dc80ed627f4567234a39c90ac05cda559$s_api.nuget.org_v3_index.json_\list_Microsoft.Data.Sqlite_page1.dat is corrupt
Warning: FindPackagesById: Microsoft.Data.Sqlite
Data at the root level is invalid. Line 1, position 1.
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite'.
The XML file C:\Users\jerom\AppData\Local\kpm\cache\ca78217dc80ed627f4567234a39c90ac05cda559$s_api.nuget.org_v3_index.json_\list_EntityFramework.Sqlite_page1.dat is corrupt
Warning: FindPackagesById: EntityFramework.Sqlite
Data at the root level is invalid. Line 1, position 1.
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite'.
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite' 50ms
The XML file C:\Users\jerom\AppData\Local\Temp\tmpC325.tmp is corrupt
Warning: FindPackagesById: Microsoft.Data.Sqlite
Data at the root level is invalid. Line 1, position 1.
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite'.
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite' 50ms
The XML file C:\Users\jerom\AppData\Local\Temp\tmpC347.tmp is corrupt
Warning: FindPackagesById: EntityFramework.Sqlite
Data at the root level is invalid. Line 1, position 1.
GET https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite'.
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='Microsoft.Data.Sqlite' 48ms
The XML file C:\Users\jerom\AppData\Local\Temp\tmpC368.tmp is corrupt
Error: FindPackagesById: Microsoft.Data.Sqlite
Data at the root level is invalid. Line 1, position 1.
----------
OK https://api.nuget.org/v3/index.json/FindPackagesById()?Id='EntityFramework.Sqlite' 50ms
The XML file C:\Users\jerom\AppData\Local\Temp\tmpC37A.tmp is corrupt
System.Xml.XmlException: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.Linq.XDocument.Load(XmlReader reader, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream, LoadOptions options)
at System.Xml.Linq.XDocument.Load(Stream stream)
at Microsoft.Framework.PackageManager.Restore.NuGet.NuGetv2Feed.<FindPackagesByIdAsyncCore>d__21.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RemoteWalkProvider.<FindLibrary>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibrary>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryByVersion>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryMatch>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryEntry>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<ExecuteCommand>d__61.MoveNext()
Error: FindPackagesById: EntityFramework.Sqlite
Data at the root level is invalid. Line 1, position 1.
----------
Restore failed
Data at the root level is invalid. Line 1, position 1.

kpm build也给了我:

Unable to resolve dependency EntityFramework.Sqlite 7.0.0-rc1-final
Unable to resolve dependency Microsoft.Data.Sqlite 1.0.0-rc1-final

然而,当我从Visual Studio构建时,从我的.dnx \ packages目录中获取包时,它工作得非常好:

Using Package dependency EntityFramework.Sqlite 7.0.0-rc1-final
Source: C:\Users\jerom\.dnx\packages\EntityFramework.Sqlite\7.0.0-rc1-final
File: lib\net451\EntityFramework.Sqlite.dll
Using Package dependency Microsoft.Data.Sqlite 1.0.0-rc1-final 3>     
Source: C:\Users\jerom\.dnx\packages\Microsoft.Data.Sqlite\1.0.0-rc1-final
File: lib\net451\Microsoft.Data.Sqlite.dll

如果我将--packages选项与kpm restore命令一起使用,它似乎有效:

kpm restore --packages C:\Users\jerom\.dnx\packages
Restoring packages for C:\Users\jerom\Documents\Visual Studio 2015\Projects\TongyiFapiao\src\TongyiFapiao\project.json
Resolving complete, 732ms elapsed
Restore complete, 738ms elapsed

但最后,当我执行

时失败了
k ef migration add initial
k ef migration apply

这是我的project.json文件:

{
    "version": "1.0.0-*",
    "compilationOptions": {
    "emitEntryPoint": true
},
"dependencies": {
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "TongyiFapiao.Models": "1.0.0-*",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "EntityFramework.Sqlite": "7.0.0-rc1-final",
    "EntityFramework.Relational": "7.0.0-rc1-final",
    "Microsoft.Data.Sqlite": "1.0.0-rc1-final",
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "System.Data.SQLite": "1.0.99",
    "TongyiFapiao.DAL": "1.0.0-*",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta8"
},
"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
},
"frameworks": {
    "dnx451": {
        "dependencies": {
        "TongyiFapiao.DAL": "1.0.0-*"
    }
 },
 "dnxcore50": {
 }
},
"exclude": [
  "wwwroot",
  "node_modules"
],
"publishExclude": [
   "**.user",
   "**.vspscc"
]
}

我尝试修改Nuget.config文件以使用不同的Nuget存储库,但它们都没有工作。 我还升级了我的KVM和DNVM,这里安装了所有.NET版本:

C:\Users\jerom\Documents\Visual Studio 2015\Projects\TongyiFapiao\src\TongyiFapiao>dnvm list
WARNING: Found a KRE_HOME environment variable. This variable has been deprecated and should be removed, or it may interfere with DNVM and the .NET Execution environment
Active Version           Runtime Architecture OperatingSystem Alias
------ -------           ------- ------------ --------------- -----
   1.0.0-beta5       clr     x64          win
   1.0.0-beta5       clr     x86          win
   1.0.0-beta5       coreclr x64          win
   1.0.0-beta5       coreclr x86          win
   1.0.0-beta8-15736 clr     x86          win
   1.0.0-rc1-final   clr     x64          win
   1.0.0-rc1-final   clr     x86          win
   1.0.0-rc1-final   coreclr x64          win
   1.0.0-rc1-final   coreclr x86          win
   1.0.0-rc1-update1 clr     x64          win
  *1.0.0-rc1-update1 clr     x86          win             default
   1.0.0-rc1-update1 coreclr x64          win
   1.0.0-rc1-update1 coreclr x86          win

我尝试更改为更新1的不同版本,但仍然存在同样的问题。

1 个答案:

答案 0 :(得分:1)

Soooo我终于找到了有趣的东西。

<强> FIRST:

kpmk命令分别重命名为dnudnx 。 除here

外,我无法找到有关它的任何信息
  

你不能在最新的软件包中使用k / kre / kvm,它不了解DNX TFM。

     

@jsacapdev您需要从Home存储库下载dnvm或坚持上周五之前存在的软件包。

2015年3月11日写的留言。感谢您就此与您进行了大量沟通......

所以我只需要运行命令dnx restore,然后实现我的最终目标,即从我的DbContext创建我的数据库。如果像我一样,你有一个多项目解决方案,你可以从数据访问层部分(DAL)拆分网站部分。解决方案是here

dnx ef migrations add InitialMigration -c TongyiFapiao.DAL.TongyiFafiaoContext -p TongyiFapiao.DAL

dnx ef database update -c TongyiFapiao.DAL.TongyiFafiaoContext

<强> BUT:

如果你转到dnx github page,你可以阅读

  

DNX(退休)

     

DNX正在退役,转而使用新的dotnet CLI命令行工具。参见:

     

http://dotnet.github.io/getting-started/

     

http://github.com/dotnet/cli

     

因此,我们不再接受此项目的更改。请在http://github.com/dotnet/cli上提交任何新问题。

太棒了,我喜欢每隔6个月更名一次,这对于理解和搜索互联网来说要好得多。我保证当第4个新命令出来时我会更新这个答案。