我是ASP.NET Core的新手,这个问题看起来很简单,但是我无法在线找到合适的解决方案。这就是问题所在。这是我正在使用的类的结构。
public class Alert
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public string AlertId { get; set; }
public string Type { get; set; }
}
这是对请求请求API的描述。
{
"alertId": "string",
"type": "string"
}
由于我在发布请求中使用[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
批注alertId
是可选的。我的目的是仅在发布请求说明中隐藏alertId
。我正在使用ASP.NET Core 3.1,EF Core(3.1.1)和Swashbuckle.AspDotNetCore(5.1.0)。请帮忙。谢谢。