Getting sqlite to work in ASP.NET 5 (vnext)

2019-09-07 03:30发布

问题:

I'm trying to get "EntityFramework.SQLite": "7.0.0-beta1" to work within ASP.NET 5.

I've created my project using Yeoman and installed EF sqlite from the package manager.

The project builds fine but when running I get:

Could not load file or assembly 'Microsoft.Framework.Logging.ILogger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'or one of its dependencies.

My project.json:

"dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Framework.Logging": "1.0.0-beta5",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta5",
    "Kestrel": "1.0.0-beta5",
    "EntityFramework.SQLite": "7.0.0-beta1"
},

I'm suspecting a versioning issue here

Things I've tried :

Tried using beta5 for EF only to have other packages breaking. I've also changed "Microsoft.Framework.Logging": "1.0.0-beta5" to the latest and got to the point where the db created successfully but then broke when it got to services.AddMvc();

I've checked the sample project into git hub: https://github.com/roboriaan/asp567

Any help would be really appreciated. Thanks

回答1:

Wait for beta 6, that includes proper SQLite support and samples. Beta 6 comes tomorrow! (July 27)



回答2:

Here is an Example https://github.com/Schr3da/ASP.net-vnext-samples project which modifies the asp.net Mvc sample to work with Sqlite

https://github.com/Schr3da/ASP.net-vnext-samples

regards Schreda



回答3:

You can't mix beta1 and beta5 packages. Given that the SQLite provider is still a work in progress, your best option is to use the latest beta7 nightly version, that fixes a few bugs. Make sure to also update your DNX runtime using dnvm upgrade -u

You can find the latest package on MyGet: http://myget.org/gallery/aspnetvnext



回答4:

Now that beta 6 is out, checkout the Getting Started with ASP.NET 5 guide. This uses SQL Server. The Getting Started with OS X guide uses SQLite.