Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Adding references to ASP.NET5 solution: PCL and CL (package)

$
0
0

I'm trying to understand how to implement ASPNET vNext solutions with external dependencies but it's hard to find some up-to-date documentation. AFAIK, I have a couple of options for importing dependencies in other projects into an ASPNET5 web app:

1. a Class Library (package), which gets packed into a NuGet package.

2. a more generic Portable Class Library, of course targeting the correct platforms. In this case I can just add the reference to the DLL, which gets copied into my web app'slib/DNX4.5.1 folder. This works only for DNX 4.5.1, not for DNX Core 5, even if my PCL was targeting ASP.NET Core 5 (with .NET 4.6 and Win10, as per the PCL project template defaults in VS2015) and has no 3rd party dependencies. Is this due to current limitations of the framework, or I'm missing something here?

As for the solution (1), which I'd like to use for moving all the EF entities into a single reusable package, I'm not managing to get it work. Here is aquick repro you can try (using VS2015 latest version with ASP.NET and Web Tools 2015 RC1 Update 1):

1. create a new ASPNET5 web app.

2. add a new Class Library (package) project to its solution.

3. and add a reference to the class library project to the web app. Everything looks good: the project.json file shows my CL project (e.g."MyProject": "1.0.0-*"), and I can compile for both DNX 4.5.1 and DNX Core 5.0. Now, I'd like to move my EF entities POCO classes to this library, so I can reuse it in other projects (e.g. console tools etc.).

4. add these NuGet packages to the CL project:

  EntityFramework.MicrosoftSqlServer
  Microsoft.AspNet.Identity.EntityFramework

5. move ApplicationUser.cs from the web app to the CL project, changing its namespace accordingly. Once I update the namespace references in the web app sources using this class, everyting compiles. Yet, when I run the web app and click LOGIN, I get the error:

  The type or namespace name 'ApplicationUser' could not be found (are you missing a using directive or an assembly reference?)

I can check the Produce outputs on build option in the CL project and see that the NuGet packages are created correctly, but how is this related to the solution? Shouldn't it work locally with the simple reference to its CL project?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>