Clean solution (project) structure with EF, Repositories, Entities

后端 未结 2 1826
生来不讨喜
生来不讨喜 2021-02-01 10:07

I like to keep the structure of the project as clean as possible. Sample:

--BlogApp.sln
  --BlogApp.Data
      BlogModel.edmx (the EF mappings)
      Post.cs (I         


        
2条回答
  •  长发绾君心
    2021-02-01 10:48

    My preferred structure is:

    Solution
      -- Common
           - Shared features used accross all layers
           - You can also place interfaces for repositories and uow here
      -- Entities - shared among DataAccess, Business (and UI in small projects)
           - T4 template + partial classes + custom enums  
           - partial classes can contain methods with domain logic => domain objects 
      -- DataAccess - all EF dependent code here
           - EDMX or code first mapping
           - Repositories
           - UnitOfWork
      -- Business - not every project needs this assembly
           - Business services 
           - Logic like workflows
           - DTOs exposed to UI
      -- UI
           - Controllers
           - Views
           - ViewModels
    

提交回复
热议问题