royfuwei / aspnetcore-clean-arch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Aspnet Clean Architecture

學習 .NET Core 開發,試著將自己理解的clean architecture 跟 DDD (Domain Driven Design) 用 .NET Core 做出簡單的開發架構。

Technologies

  • Domain Drive Design (DDD)
  • Clean Architecture
  • Dependency Injection (DI)
  • Inversion of Control (IoC)
  • Mediator Pattern (中介者模式)
  • CQRS 模式? (不太算是,因為目前是把Query 也用Mediator 方式)
  • Event Driven

功能

  • Rest API

Getting Started

# start Services/API service
dotnet run src/Services/API

docker

目前先在./ 使用docker build,之後再來想怎麼到不同src/Services/...裡面個別配置Dockerfile

docker build -t aspnetcore-clean-arch:dev -f .
docker run -it --rm -p 5000:80 aspnetcore-clean-arch

Test

使用xUnit

dotnet test

# or

dotnet test test/Domain.UnitTests

Entity Framework Core

Migration

appsettings.json

    "UseInMemoryDatabase": false,

src/Services/API project 使用Migrations

# 
dotnet ef database update --project src/Infrastructure --startup-project src/Services/API

# 初次使用 或是 有異動context 跑migration
dotnet ef migrations add InitialCreate --project src/Infrastructure --startup-project src/Services/API --output-dir Persistence/EFCore/Migrations

# update database
dotnet ef database update --project src/Infrastructure --startup-project src/Services/API

# drop database
dotnet ef database drop --project src/Infrastructure --startup-project src/Services/API

Entity Framework Core 使用UseInMemoryDatabase 無法使用dotnet ef


開發相關

開發文件

規劃導入的項目


Reference

About


Languages

Language:C# 99.6%Language:Dockerfile 0.4%