1

App version - ASP.NET 5 beta7 build. Entity 7. OS Win x64.

I have a problem with attaching Sqlite to my app. I'm recieving Unable to load DLL 'sqlite3' (System.DllNotFoundException) or IncorrectFormat (System.BadImageFormatException) Errors. It seems that app can't find SQLite dll & lacks proper reference.

When switching between dnx versions, errors change (tried in both clr & coreclr). Errors - Former for x86, latter for x64. However, in both instances dnx & sqlite versions are matched.

My global.

{
  "projects": [ "src", "test" ],
  "sdk": {
    "version": "1.0.0-beta7",
    "runtime": "clr",
    "architecture": "x64"
  }
}

My project.json partial.

"dependencies": {
  "Microsoft.AspNet.Diagnostics": "1.0.0-beta7",
  "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-beta7",
  "Microsoft.AspNet.Mvc": "6.0.0-beta7",
  "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta7",
  "Microsoft.AspNet.Server.IIS": "1.0.0-beta7",
  "Microsoft.AspNet.Server.WebListener": "1.0.0-beta7",
  "Microsoft.AspNet.StaticFiles": "1.0.0-beta7",
  "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta7",
  "Microsoft.Framework.Configuration.Json": "1.0.0-beta7",
  "Microsoft.Framework.Logging": "1.0.0-beta7",
  "Microsoft.Framework.Logging.Console": "1.0.0-beta7",
  "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta7",
  "Microsoft.AspNet.Session": "1.0.0-beta7",
  "EntityFramework.SqlServer": "7.0.0-beta7",
  "EntityFramework.Commands": "7.0.0-",
  "EntityFramework.Sqlite": "7.0.0-beta7",
  "sqlite": "3.8.4.2"   (Nuget)
},

There is sqlite3.dll file in root but added reference just transforms into Nuget dependency 3.8.8.x within VS15.

Startup.cs partial.

public void ConfigureServices(IServiceCollection services) {
        services.AddEntityFramework()
            .AddSqlite()
            .AddDbContext<EF7oakContext>(options => options.UseSqlite(Configuration["SqliteString"])); }

... points to config.json.

"Data Source=<path>\\<DBname>.sqlite;"

I tried configuration within Context but if I understand correctly, that's just duplicating config.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
     optionsBuilder.UseSqlite("Data Source=<path>\\<dbname>.sqlite;"); }

Simple custom Seed.cs.

public static void Seed(this IApplicationBuilder app) {
    var context = app.ApplicationServices.GetService<MyContext>();
    if (!context.People.Any()) {
        context.People.AddRange(
            new Sth { a = "a", b = "b" }
            (...) 
            );
            context.SaveChanges(); }
            (...)
    }

I checked Stack-link-1 and Stack-link-2, but solutions given there are not working.

Recap:

  • Matched sqlite3 version added as app reference. Used dnvm use [version]
  • Downloaded latest sqlite (sqlite-link) and put it in my app folder with unchanged name
  • With each runtime - packages restored with dnu restore
  • I want to match platform build options for sqlite, but there is no option in VS15, per @B. Clay Shannon similar problem from link no.1 above (earlier ASP v.)
  • App works with local SQL Server DB.
  • Migrations working.

I would appreciate any help or even loose suggestions.

Community
  • 1
  • 1
baftinho
  • 33
  • 4

0 Answers0