Search code examples
cachingasp.net-coredotnet-cli

Creating ASP.NET Core SQL Cache table


I'm trying to generate the Distributed SQL Server Cache for ASP.NET Core 2.0, using the CLI, but I only get an error. The instructions say to execute

dotnet sql-cache create <connection string>  <schema>  <table name>

but when I do, it simply responds with No executable found matching command "dotnet-sql-cache".

I have installed Microsoft.Extensions.Caching.SqlConfig.Tools 2.0.0 on that project. So it should work from the project root, no?

When I execute dotnet -h, I get .NET Command Line Tools (2.0.2), etc. Surprisingly enough, sql-cache is not listed there among the SDK commands, alongside new, restore, run, migrate, etc. Shouldn't it be?


Solution

  • I have found installing certain Tools to be troublesome when I have used Nuget either by using the CLI or the package manager. In the past I have had to directly install a tool in the csproj file. Check your csproj file and see if the installation of the SqlConfig took hold. If it has not just add it and run a dotnet restore. Here is an example of how to "hard code" the tool. ```

    <ItemGroup>
    <DotNetCliToolReference 
         Include="Microsoft.Extensions.Caching.SqlConfig.Tools" 
         Version="2.0.0" />
    </ItemGroup>
    

    Also, here is a link to where a better explanation to the issue. It also recommends installing Microsoft.Extensions.Caching.SqlServer if you have not already done so but I would try this solution first. Hope this helps.