Open christianspecht opened 8 years ago
I have a similar problem. I have created an ASP.NET application using EF Core. I have a DataLayer which contains the EF DbContext and I used Ben Cull's approach to overcome the current limitation of EF Core. I then want to reference the DataLayer from a Class Library (.NET Core) called ServiceLayer. When I do that I get the same error as @christianspecht lists above.
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"frameworks": {
"netcoreapp1.0": { }
},
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0"
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final"
}
}
}
I have tried changing the ServiceLayer over to framework "netcoreapp1.0". At that point I can add the reference, but it does not compile. The error when compiling with dotnet build
is given below NOTE: EfCoreContent is a public class in the DataLayer.
C:\Users\Jon\Documents\Visual Studio 2015\Projects\EFCoreExample\src\ServiceLayer\BookServices\BookListDto.cs(43,83): error CS0234: The type or namespace name 'EfCoreContent' does not exist in the namespace 'DataLayer.EfCode' (are you missing an assembly reference?)
Any suggestions? I looks like having multiple projects/assemblies is a little difficult in .NET Core at the moment.
@JonPSmith I solved this problem by making all of my class libraries netcoreapp1.0. I think the error you're getting when you tried it is a legitimate architecture error. Do you have the right "using" at the top of your service layer class (BookListDto)?
Thanks @bjcull,
I did try to do that but I must have got the project.json wrong. My using
statement is pretty simple. Can you add an example project.json file to this thread sometime. It might help me and others.
UPDATE: Sorry, should have said an example of a Class Library which references the framework netcoreapp1.0.
I found a similar solution in the meantime.
As I said earlier, what I'm actually trying to do is updating a .NET Core RC1 app to .NET Core RTM. The sample project I created for this issue is similar to my real project (console app with test library), that's why I was trying to create that reference from the library to the app.
In the meantime, I discovered the current xUnit.net guidance for .NET Core.
There's the same solution that you guys already mentioned: set the test project to netcoreapp1.0
They have a complete project.json
example ("Replace the contents of your project.json file with the ones listed below"), and with this, I managed to convert my actual project to .NET Core.
@JonPSmith: Here's the commit with the changes and here is the project.json
of a class library with netcoreapp1.0
.
Right now, my app is compiling and all the tests are running (except one that is failing, but that has nothing to do with this issue here).
Hi @christianspecht,
Thanks for the link. Further work on this problem suggests that the compile errors about a missing using
statement were an artefact of Visual Studio. It turns out that Visual Studio 2015 (update 3) was throwing up errors with dotnet build
did not find. All very confusing.
I am not totally sure what solved my problem as I, in the end, used another approach to overcome it. However I think removing and then reloading a project, and/or exiting VS and restarting it helped.
im having the exact same problem as @JonPSmith I have a datalayer that uses entitframework, then I discovered that I have to covert it to a console app to get entityframework core to work which it did.
The problem occurs when you want to create a classlibary that takes a dependency on the datalayer.
Runing aspnetcore on the full .net framework with entityframework 6.x has been a breeze and much fun. This .netcore ClassLibrary and entityframeworkcore on dotnetcore issue is a huge mess. I have lost over a week on a project getting burned on almost everything.
The only workable solution for me was to covert all classlibraries to console apps which sucks. The entire team will be waiting for dotnetcore 2.0 release by spring hopping these issues are sorted out by then
the real pain here is that they do advertise about linux a lot but nothing works. their promise is just good enough for samples not real world projects. i got tired and i change to nodejs. atleast it's works as they say. the issue #695 in here and the another issue that you can not run update-database in .net core library project are very good for consuming time, i spent 3 days without 1inch of progress. these the microsoft way , they make believe that they are doing great but in real it's just a big mess.
found a simple solution to the problem. just need to play with the project.json . I will post a youtube video of the solution. But its still based on making it look like a console app. Haven't tried it fully on ubuntu yet.
hai dont worry about that its a simple thing go to the project folder navigate to debug netcoreapp2.0 if you are in dotnet core just delete all the files now open project in visual studio and then try to add ... now it will add as expected
I'm using Visual Studio 2015 Community Edition (previously with .NET Core RC1) on Windows 8.1.
I updated to .NET Core RTM and now I'm trying to create a new console app with unit tests. So I have a solution with a console app and a library (for the tests), and I need to reference the console app from the library. But I'm not able to create that reference.
Here is my test project on GitHub: https://github.com/christianspecht/CoreRtmReferenceTest
What I did so far:
Now when I try to reference the console app from the library, I get the following error message:
I googled ".NETStandard" and ".NETCoreApp" and found this, and now my brain hurts.
Plus, I already read this, but I think it doesn't apply to me, because I want to do exactly the opposite. (this link is about adding references FROM apps TO libraries)
However, from what I understand from this link, there are problems with referencing compiled DLLs right now, but project references inside the same solution should work. In fact, referencing the library from the console app does work, just not the other way round.
Is there any solution to do this outside Visual Studio?
What I was actually trying to do: I have an existing .NET Core RC1 console app with test library which I want to update to .NET Core RTM. This issue blocks me from upgrading, because I'm not able to create that reference there either.