A ready to use FakeDbSet for faking Entity Framework code.
The version of EntityFramework I used for the data access code and the version needed for FakeDbSet were different. Running the unit test would throw an exception:
Could not load file or assembly ‘EntityFramework, Version=184.108.40.206,
Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)
I remembered the solution Visual Studio offered the previous time and added a binding redirect. This solved the problem.
<configuration> <!-- other stuff removed for clearness --> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="EntityFramework" culture="neutral" publicKeyToken="b77a5c561934e089" /> <bindingRedirect oldVersion="220.127.116.11" newVersion="18.104.22.168" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration>
Not to say I’m happy with a version number in my config, but this is in my unit test and that is not (currently) part of my product.