Skip to content
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

Removing reference to Infra project in Web Project #5

Closed
funzeye opened this issue May 31, 2018 · 1 comment
Closed

Removing reference to Infra project in Web Project #5

funzeye opened this issue May 31, 2018 · 1 comment

Comments

@funzeye
Copy link

funzeye commented May 31, 2018

I notice you have added, and are referencing, the Infrastructure layer in your UI layer (in startup.cs) for DI purposes.

Can you recommend any ways in which to remove this dependency? (Apart from using StructureMap!)

I have been reading about creating a factory in the Core layer to accomplish this?

Only problem I see with using the 'factory in Core' approach is that I would need to reference the Infrastructure layer in the core layer to do this, removing the core reference in the infrastructure project ( to avoid circular dependency) which completely changes the role of the Core project (not really "central" anymore, just a middle layer).

@funzeye funzeye changed the title Removing refernence to Infra project in Web Project Removing reference to Infra project in Web Project May 31, 2018
@ardalis
Copy link
Owner

ardalis commented May 31, 2018

I would avoid putting anything in Core that would require a reference to Infrastructure. In fact this will be impossible to do at compile time due to the circular dependency as you noted. I have an article on accomplishing what you're looking for here:
https://ardalis.com/avoid-referencing-infrastructure-in-visual-studio-solutions

I haven't updated it yet for .NET Core, partly because .NET Core doesn't make it easy to configure EF Core outside of Startup (in the web project). However, looking at the technique used in that article might give you some ideas, and it's on my backlog to get it working in an ASP.NET Core solution and write another article... Let me know if you figure something out that works well.

@funzeye funzeye closed this as completed Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants