iT邦幫忙

1

請問asp.net core webapi 如何在DB first的情況使用欄位驗證?

  • 分享至 

  • xImage

我平常在使用MVC專案的時候,會直接採用MetaDataType的方法,但webApi在這方面不能用,FluentApi可以使用在驗證,但對於欄位中對Json的序列化行為[JsonIgnore]等不能使用。

想請問還有什麼方法是在webapi能使用的嗎?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
天黑
iT邦研究生 5 級 ‧ 2024-10-14 17:27:24

你有試過 https://learn.microsoft.com/en-us/ef/core/cli/powershell#scaffold-dbcontext 這上面的-DataAnnotations 指令嗎? 也許是你需要的

我要發表回答

立即登入回答