Dapper.NET Configuration required


Example

  1. install the required Microsoft.SqlServer.Types assembly; they are not installed by default, and are available from Microsoft here as "Microsoft® System CLR Types for Microsoft® SQL Server® 2012" - note that there are separate installers for x86 and x64.

  2. install Dapper.EntityFramework (or the strong-named equivalent); this could be done via the IDE's "Manage NuGet Packages..." UI, or (at the Package Manager Console):

    install-package Dapper.EntityFramework
    
  3. add the required assembly binding redirects; this is because Microsoft ships v11 of the assemblies, but Entity Framework asks for v10; you can add the following to app.config or web.config under the <configuration> element:

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Microsoft.SqlServer.Types" 
              publicKeyToken="89845dcd8080cc91" />
          <bindingRedirect oldVersion="10.0.0.0" newVersion="11.0.0.0" />
        </dependentAssembly>
      </assemblyBinding>
    </runtime>
    
  4. tell "dapper" about the new type handlers available, by adding (somewhere in your startup, before it tries using the database):

    Dapper.EntityFramework.Handlers.Register();