簡體   English   中英

在CreateParameter上的ASP.NET 5 vNext EF7 SQLite TypeLoadException

[英]ASP.NET 5 vNext EF7 SQLite TypeLoadException on CreateParameter

當我嘗試加載我的網站或嘗試通過k ef migration apply應用我的遷移時出現以下錯誤

An unhandled exception occurred while processing the request.

TypeLoadException: Could not load type 'Microsoft.Data.SQLite.SQLiteParameter' from assembly 'Microsoft.Data.SQLite, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

我的背景:

using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;

namespace MvcSample.Web.Models
{
    public class HelloMvcContext : DbContext
    {
        public DbSet<User> Users { get; set; }

        protected override void OnConfiguring(DbContextOptions options)
        {
            options.UseSQLite(@"Filename=hellomvc.db");
        }

        protected override void OnModelCreating(ModelBuilder builder)
        {
            builder.Entity<User>().Key(m => m.ID);
            base.OnModelCreating(builder);
        }
    }
}

我的startup.cs:

using Microsoft.AspNet.Builder;
using Microsoft.Framework.DependencyInjection;
using MvcSample.Web.Models;

namespace HelloMvc
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorPage();

            app.UseMvc();

            app.UseWelcomePage();
        }

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddEntityFramework()
                        .AddSQLite()
                        .AddDbContext<HelloMvcContext>();

            services.AddMvc();
        }
    }
}

我的project.json:

{
    "dependencies": {
        "Kestrel": "1.0.0-beta1",
        "Microsoft.AspNet.Diagnostics": "1.0.0-beta1",
        "Microsoft.AspNet.Hosting": "1.0.0-beta1",
        "Microsoft.AspNet.Mvc": "6.0.0-beta1",
        "EntityFramework.SQLite": "7.0.0-beta1",
        "EntityFramework.Commands" : "7.0.0-beta1",
        "Microsoft.AspNet.StaticFiles": "1.0.0-beta1",
        "Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta1",
        "Microsoft.Framework.OptionsModel": "1.0.0-beta1",
        "kmon": "0.3.0"
    },
    "commands": {
        "web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5001",
        "kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
        "mon" : "kmon --ext cs,json,js --server kestrel",
        "ef" : "EntityFramework.Commands"
    },
     "frameworks": {
        "aspnet50": {},
        "aspnetcore50": {}
  }
}

SQLite beta 1已有8個月的歷史,並且在該版本支持遷移之前已停止工作。 SQLite提供程序的工作已經重新啟動,通過檢查測試,它現在看起來像支持遷移,但在您的應用程序中工作的唯一方法是從dev中提取EntityFramework的源並在本地構建它。 或者你可以等到beta5發布。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM