I get the following error when I attempt to load my website, or attempt to apply my migrations via 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'.
My context:
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);
}
}
}
My 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();
}
}
}
My 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 is 8 months old and work was discontinued before migrations were supported in that build. Work on the SQLite provider has been restarted and by inspecting the tests it now looks like migrations are supported, but the only way for this to work in your application is to pull the source for EntityFramework from dev and build it locally. Or you can wait until beta5 is released.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With