軟件介紹:git
Magic是一個CRUD後端生成器,內置於ASP.NET內核中。它的目的是讓你「神奇地」作一些無聊的事情,經過使用自動化技術,建立80%的CRUD端點,自動包裝MySQL或MS SQL Server數據庫,同時你能夠專一於有趣的事情。github
1、參考文檔數據庫
一、適合 ASP.NET Core 的超級-DRY開發npm
二、Magic 官網:https://polterguy.github.io/getting-started/json
2、實現步驟:後端
To get started with Magic you’ll need the following installed.服務器
MySQL or Microsoft SQL Server.app
Visual Studio Code, or Visual Studio if you’re on Windowsless
NodeJS - To serve the frontend/dashboardfrontend
Angular, which is installed using npm install -g @angular/cli
after installing NodeJS
DotNet CLI - Unless you’re using Visual Studio on Windows
Open Visual Studio Code in your magic folder
Edit your appsettings.json
file, and modify your MySQL and/or MSSQL connection strings
Open one terminal window and go to magic.backend
Run dotnet run
in the magic.backend terminal
Open another terminal window and go to frontend
Run npm install
in this terminal
When npm install from above is done, run ng serve
in the frontend terminal
Open your browser and point it to http://localhost:4200
Login with 「root/root」 as your username/password
Click the 「Crudify」 menu item
Choose your database and your table
Click the 「Crudify」 button
When you have created your first CRUD endpoints, you can click the 「Endpoints」 menu item, and try out your newly created HTTP REST endpoints.
若是你在一家諮詢公司工做,可能每一年都會啓動幾個具備相似需求類型的新項目,其中須要解決每一個新項目的共性。瞭解了客戶端需求和一些初始實現以後,即可以使用超級 DRY 方法在幾秒鐘內完成整個項目。固然,經過標識常見模塊(如身份驗證和受權),能夠進一步重用項目中的元素組合。經過在常見 Web API 項目中實現這些模塊,能夠將它們應用到任何新項目中,這些新項目會帶來與你之前看到過的相似的問題。
爲了方便記錄,此操做聽起來很簡單,但事實上避免重複很難。它須要反覆重構的意願。完成重構時,還須要進一步進行重構。但好處是不容忽視的。DRY 原則可讓你近乎魔術般地建立代碼,只需揮動基架魔杖,並借用現有部件組合模塊。
最後,這裏闡述的原則能夠幫助你利用現有最佳作法建立本身的 Web API,同時避免重複。這種方法能夠帶來不少好處,但願它能夠幫助你領會到 DRY 的美妙之處。
儘管出於學術緣由,Magic的大部分源代碼都是公開的,但它並非開源的或免費的軟件,咱們會對您要運行Magic的每一個服務器/主機名/DNS記錄收取費用。不過,在本地開發機器上評估和使用Magic是免費的。若是您想使用Magic建立免費的開源軟件,咱們還能夠給您一個免費的許可證密鑰。請在此處或隨附的許可證文件中閱讀更多信息。