entity-frameworkwindows-servicesasp.net-corecode-sharing

Shared library for asp.net core app and windows service


I have an ASP.NET Core web app and a Windows Service that both access the same database. I am using Entity Framework Core as an ORM. I would like to be able to create a library package that encapsulates all data access (ie. a Repository) and can be shared by both the web app and the service.

Entity Framework Core appears to only be supported in DNX applications, and Windows Services, as standard Windows applications, cannot reference DNX projects. Is there any way of creating a DNX Windows Service, or another approach that would work?

Creating a standard windows class library with EF 6.x is not an option as the Repository has already been written in EF Core.


Solution

  • Just discovered my mistake, Entity Framework Core is supported in standard windows projects, so it looks like I have my solution: create a Repository class library that accesses the database using EF Core and reference it from both the ASP.NET Core and Windows Service apps.