gpt4 book ai didi

c# - CreateParameter 上的 ASP.NET 5 vNext EF7 SQLite TypeLoadException

转载 作者:IT王子 更新时间:2023-10-29 06:29:46 25 4
gpt4 key购买 nike

当我尝试加载我的网站或尝试通过 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();
}
}
}

我的项目.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 提供程序上的工作已经重新启动,通过检查测试,现在看起来支持迁移,但要在您的应用程序中使用它的唯一方法是从开发人员中提取 EntityFramework 的源代码并在本地构建它。或者您可以等到 beta5 发布。

关于c# - CreateParameter 上的 ASP.NET 5 vNext EF7 SQLite TypeLoadException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28264341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com