Here is situation: I have DAL assembly that connects to DB using EntityFramework code fist. Recently we added strong names to our assemblies, including DAL. Now, when connecting to database, if last migration was on previous version of DAL (or different public token), I get exceptions like this one:
Could not load file or assembly 'MyProject.DAL, Version=126.96.36.199, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Current version of DAL is 188.8.131.52. Exception is database-specific, one of older databases was looking for 184.108.40.206. If I create new blank migration on current version and apply it, exception stops, but if I change DAL version again, I get exception again. What causes this exception and how do I prevent it from happening on every DAL version update?
Recently we added strong names to our assemblies, including DAL
For which of these reasons are you doing that?
When you change the public key token (by strong-naming) or increment the AssemblyVerion (not the AssemblyFileVersion) you are breaking backwards-compatibility.
After such a change you should probably just start over with a new initial migration.
You might be able to work around the AssemblyVersion difference with a Binding Redirect.
User contributions licensed under CC BY-SA 3.0