Coder Social home page Coder Social logo

bs.demoshoptemplate's Introduction

BS.DemoShop

環境設定

  1. SDK : .NET 7.0(或以上)。
  2. 連線字串設定 : 修改appsettings.json或者使用使用者密碼(sectets.json)(參考資料:在 ASP.NET Core 中開發中安全儲存應用程式密碼)。
  3. 遷移(更新)資料庫 :
    • 使用.Net Core CLI : dotnet ef database update --project ./DemoShop.Infrastructure/ --startup-project ./DemoShop.Web/
    • 使用Visual Studio PMC(預設專案為DemoShop.Infrastructure) : Update-Database

資料庫異動流程(使用.Net Core CLI)

以下兩種方式建議第一次建立Entity及DbContext時可以使用Scaffold方式還原;遷移資料庫時再使用Migration的方式更新到其他環境的資料庫。

Code First

  1. 修改Entity Model。
  2. 新增Migration異動紀錄 : 指令 dotnet ef migrations add <Migration name> --project ./DemoShop.Infrastructure/ --startup-project ./DemoShop.Web/ --output-dir ./Data/Migrations
  3. 遷移(更新)資料庫 : dotnet ef database update --project ./DemoShop.Infrastructure/ --startup-project ./DemoShop.Web/

Code First From DB(Scaffolding)

  1. 修改資料庫Schema。
  2. Scaffolding資料庫 : dotnet ef dbcontext scaffold "Name=ConnectionStrings:BSDemoShopConnection" Microsoft.EntityFrameworkCore.SqlServer --output-dir ../DemoShop.ApplicationCore/Entities --context-dir ../DemoShop.Infrastructure/Data --namespace DemoShop.ApplicationCore.Entities --context BSDemoShopContext --context-namespace DemoShop.Infrastructure.Data --startup-project ./DemoShop.Web --data-annotations --force
  3. 修改IRepository<T>EfRepository<T>的泛型約束 : 將BaseEntity修改為class(沒修改的話會無法建置)。

其他

bs.demoshoptemplate's People

Contributors

andyhuang1223 avatar q20274982 avatar weberyanglalala avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.