1

I have created a simple console application using VS 2013 and .Net 4.5 framework. I am trying to achieve a very simple objective of using Entity Framework & SQLite, I wish to create a table from my model, using the code-first approach. I have installed the NuGet package to be able to use LINQ to SQLite in my project.

Below is the code of my application:

 static void Main(string[] args)
 {
     string _databaseFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "TestSqliteDb.sdb");

     if (!File.Exists(_databaseFilePath))
         SQLiteConnection.CreateFile(_databaseFilePath);

     using (var testDb = new TestMovieDbContext())
     {
         testDb.AppConfigTable.Add(
             new ApplicationConfiguration
             {
                 ConfigKey = "CreatedDate",
                 ConfigValue = "12-03-2015"
             });
      }

public class TestMovieDbContext : DbContext
{
    public TestMovieDbContext()
        : base("name=TestDbConStr")
    {
    }

    public DbSet<ApplicationConfiguration> AppConfigTable { get; set; }
}

public class ApplicationConfiguration
{
    [Key]
    public string ConfigKey { get; set; }
    public string ConfigValue { get; set; }
}

So, here I'm simply trying to add a new ApplicationConfiguration obj to the AppConfig DbSet of the DbContext.

However, at the time of executing the Add method line, the application throws the below exception:

System.IO.FileLoadException was caught
  HResult=-2146234304
  Message=Could not load file or assembly 'System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139' or one of its dependencies. The located assembly`s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=mscorlib
  FileName=System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
  FusionLog==== Pre-bind state information ===
LOG: DisplayName = System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
 (Fully-specified)
LOG: Appbase = file:///E:/Projects/TestApplications/LinqToSqliteDemo/LinqToSqliteDemo/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
===
> LOG: This bind starts in default load context.
LOG: Using application configuration file: E:\Projects\TestApplications\LinqToSqliteDemo\LinqToSqliteDemo\bin\Debug\LinqToSqliteDemo.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Data.SQLite, Version=1.0.66.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139
LOG: Attempting download of new URL file:///E:/Projects/TestApplications/LinqToSqliteDemo/LinqToSqliteDemo/bin/Debug/System.Data.SQLite.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
abatishchev
  • 92,232
  • 78
  • 284
  • 421
Lucifer
  • 2,097
  • 8
  • 33
  • 59
  • possible duplicate of [The located assembly's manifest definition does not match the assembly reference](http://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference) – JNYRanger Mar 13 '15 at 19:02
  • Version `1.0.66.0` seems pretty old, I'm not sure that will be compatible with .Net 4.5 ([See here](http://stackoverflow.com/a/13496617/95573)) – SwDevMan81 Mar 13 '15 at 19:16

1 Answers1

0

I am using EF 6.1.3, SQLite 1.0.96.0 and SQLite.CodeFirst 0.9.5.0 on Visual Studio 2013 Update 4 without such issues. Try updating.

GregC
  • 7,517
  • 2
  • 48
  • 63