NuGet package referencing issues in new Nuget Class Library template in Visual Studio 2015

entity-framework-core visual-studio-2015


I've been working with the pre-release version of VS2015 recently which gave the option of a "ASP.NET 5 Class Library" which has since changed in RTM to simply "Class Library (Package)" With the description PREVIEW - A project template for creation a class library as a NuGet package that can target any platform

I recently created one of these new Class Library projects and added in into a solution which also included an ASP.NET 5 project. I used the Package manager console to add in references to Entity Framework 7 to both projects which worked fine, adding the correct text into the project.json files in both projects (the Reference section in VS also updated accordingly). But when trying to add using Microsoft.Data.Entity; to my Class Library project I cannot reference it at all. It works fine in the ASP.NET project.

Intellisense gives me options for 'Microsoft.CSharp' and one other namespace, but not 'Data'. I've tried creating an entirely new solution from scratch but this still hasn't helped.

I also tried adding references to the dnx XUnit stuff to the project as per their website's guidelines but these did not work either.

EDIT: I think the problem lies somewhere with the dotnet Target Framework Moniker(TFM) which looks to have been introduced in DNX SDK 1.0.0-beta5 as there are not issues when using dnx451 in 1.0.0-beta4

Accepted Answer

I've finally found a post on github from the author of xunit, Brad Wilson who states that currently the dotnet TFM doesn't work as you would expect and that the dnx451 and dnxcore50 are better TFM's to target.

Brad Wilson's comment

Link to comment

Popular Answer

I just went through the process of adding 2 projects. A class library and an mvc 6 project. I could duplicate your issue. To fix it I edited the class library project.json and changed the property under "frameworks" from dotnet to the 2 frameworks dnx451 and dnxcore50 as is found in the web project. Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why