EF Core 2.0.0 and Redis.Core 1.0.3 don't work together

.net-core c# entity-framework-core redis

Question

I tried to setup a .net core console application which uses EF core 2.0.0 and Redis.Core 1.0.3 (both are the current latest version).

Unfortunately if you try to put both into one application it won't even start. Even if you try to set a breakpoint right at the beginning or start debugging with Step into or Step Over doesn't help. All you get is this: The application is in break mode

I think there happens some kind of type load exception or something similar. So far to reproduce the problem is quite easy with this project:

Project File (MyProject.csproj)

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Caching.Redis.Core" Version="1.0.3" />
  </ItemGroup>

</Project>

Application (Program.cs)

using Microsoft.Extensions.Caching.Redis;
using Microsoft.Extensions.Options;

namespace MyApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            var cache = new RedisCache(Options.Create(new RedisCacheOptions()));
        }
    }
}

Anybody an idea or solution?

1
2
10/10/2017 2:23:22 PM

Accepted Answer

The problem is that

  • Microsoft.Extensions.Caching.Redis.RedisCache 1.0.3 depends on Microsoft.Extensions.Caching.Abstractions 1.0.3
  • Microsoft.EntityFrameworkCore 2.0.0 depends on Microsoft.Extensions.Caching.Abstractions 2.0.0

If you look at the Output Window, you will get:

TypeLoadException: Method GetAsync in type Microsoft.Extensions.Caching.Redis.RedisCache from assembly 'Microsoft.Extensions.Caching.Redis, Version=1.0.3.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' does not have an implementation.

So: either wait until RedisCache gets updated to 2.0.0 or use EntityFrameworkCore < 2.0.0

2
10/10/2017 2:49:01 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow