I have built a layered architecture to distance the dependencies on the ASP.Net Core MVC web project. I have:
MyWebApp.Data – which contains all the EF Context classes
MyWebApp.Repositories – which uses LINQ to get the right data from the context classes
MyWebApp.Services – which uses the unit of work pattern to group all repositories together and uses them before saving all changes in 1 big transaction.
MyWebApp.Web – And finally, the MVC web app which has a dependency on the Services project only.
I want to use a code-first implementation of EF Core so I need to generate tables and do some migrations but I have just realised this might be a problem because I am not directly using the context classes.
Is this a bad way of doing this? I have been following guides I have found online who say this architectural design works well for them but maybe I have misunderstood.
Do I need to use services.AddDbContext()? I am going to be adding the service classes using “services.AddSingleton<T>()” if that’s relevant.
Any advice for code-first EF Core generated tables and this style of designing an app would be much appreciated! Thanks 🙂