-
Notifications
You must be signed in to change notification settings - Fork 9.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to resolve service for type 'Core.Data.CoreContext' while attempting to activate 'Core.Data.Repositories.UnitOfWork' #2140
Comments
Solution was: So instead of |
@davidfowl
Now all DbSets ,except those shared in Core project, are not accessible. |
Couldn't (or shouldn't :)) you actually use Your Core project:
Your App project
This way, whenever your request |
Thx tymarats, this solved it. |
I have part of WebAPI application that I want to move to separate project as class library.
It is common base structure that almost every app has so idea is to make it easy shareable.
Application type is:
ASP.NET Core Web Application / .NET Framework - ASP.NET Core 2.0 / Web API
What I have done in that direction is created a project named Core and moved those shared elements there, including Base Entities (e.g. User, Settings, etc), CoreContext, UnitOfWork, Generic Repository, BaseRepositories,...
In the Main project of app there are others Entities, AppContext that inherits CoreContext, more Repositories, and all Controllers, ...
I was able to build the app but when starting it get the following error:
Problem seems to be that
UnitOfWork
class is in Core project and in Main project isStartup.cs
with methodConfigureServices
that hasservices.AddTransient<IUnitOfWork, UnitOfWork>();
.Is this a bug or am I just not configuring it correctly and how could it be achieved, if possible at all?
Further technical details
NetCore & EF Core version: 2.0
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
IDE: Visual Studio 2017 15.3
Operating system: Windows 10
CODE Sample:
The text was updated successfully, but these errors were encountered: