解决办法:外键添加[JsonIgnore] 特性即可解决
/// <summary> /// 文章相册 /// </summary> [Table("ArticleAlbum")] public class ArticleAlbumModel { /// <summary> /// 主键ID /// </summary> [Display(Name = "主键ID")] [Key, DatabaseGenerated(DatabaseGeneratedOption.None)] [StringLength(16)] public string? Id { get; set; } = Utils.GuidTo16String(); /// <summary> /// 所属文章ID /// </summary> [Display(Name = "所属文章")] [ForeignKey("Article")] public string? ArticleId { get; set; } /// <summary> /// 文章信息 /// </summary> [JsonIgnore] public virtual ArticlesModel? Article { get; set; } }
标签:解决办法,set,get,EF,ID,文章,序列化,public From: https://www.cnblogs.com/microsoft-zh/p/17658493.html