#.NET DbContext
1 messages · Page 1 of 1 (latest)
Short answer:
Either your root directory with your Program.cs or smth like Infrastructure\ApplicationDbContext.cs
Long answer:
That depends on the architecture. If you're working on a bigger project, you usually split different concerns up in different projects e.g.
App.Application
- Contains the application startup code and configures all dependencies on the Service Collection. If you don't have the Api project, controllers go here
App.Api / Presentation
- Contains the code that handles external concerns such as your controllers
App.Infrastructure
- Contains implementations for third party dependencies that you use in your app. If you don't have the persistence project, you'd also configure the db stuff here.
App.Persistence
- Contains the implementation for persistence related stuff. E.g. your database, caching...
App.Core / App
- Contains the application code that creates new entities, updates them and stuff like that... If you don't need the domain project, you can also put that stuff in here (I guess..)
App.Domain
- Contains the entities, repositories (if you use that pattern), DDD related objects and other things like that.
Small intro into the "clean architecture" architecture https://www.youtube.com/watch?v=tLk4pZZtiDY
This is a very elaborate architecture which you prolly don't need to use unless you're working on quite a large project which means you can consolidate some of the projects into one. (There are of course other architectures as well but this is the one I'm most familiar with). For a less elaborate example, check out https://github.com/dotnet-architecture/eShopOnWeb/tree/main/src or https://github.com/dotnet-architecture/eShopOnContainers/tree/dev/src which is more microservice oriented.
Support me on Patreon to access the source code:
https://www.patreon.com/milanjovanovic
You've heard about Clean Architecture before? In this video, I'm going to show you how to set up the Clean Architecture using .NET 6 and CQRS with MediatR.
How I Approach Clean Architecture Folder Structure
https://www.milanjovanovic.tech/blog/clean-archite...
Sample ASP.NET Core 6.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder. - eS...