![](/img/trans.png)
[英]Sending and receiving different models over json with webapi and entity framework
[英]How can I use Microsoft.AspNet.WebApi.HelpPage to document Entity Framework data models if they are constantly over-written?
我的任務是使用代碼注釋和Microsoft.AspNet.WebApi.HelpPage包來記錄我們的API。
問題是我們使用實體框架,並且我們用於數據模型的類是自動生成的,並且在下次更新模型時將被覆蓋。 發生這種情況時,我的代碼注釋(以及我的文檔)將丟失。
將Microsoft.AspNet.WebApi.HelpPage與實體框架一起使用的最佳方法是什么?
使用NuGet安裝Microsoft.AspNet.WebApi.HelpPage
程序包
using System.Web.Routing;
添加using System.Web.Routing;
到Global.asax AreaRegistration.RegisterAllAreas();
到Global.asax中的Application_Start() App_Data/YOUR-PROJECT-NAME.xml
轉到Areas> HelpPage> App_Start> HelpPageConfig注釋行37,以使用XML文檔文件中的文檔。
config.SetDocumentationProvider(new XmlDocumentationProvider(HttpContext.Current.Server.MapPath("~/App_Data/YOUR-PROJECT-NAME.xml")));
結束
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.