随便搞两个实体类举例: 标红处所展示会生成外键关系
public class Book { /// <summary> /// id /// </summary> public int Id { get; set; } /// <summary> /// 书本名称 /// </summary> public string Name { get; set; } /// <summary> /// 价格 /// </summary> public decimal Price { get; set; } /// <summary> /// 所属类型 /// </summary> public string Type { get; set; } /// <summary> /// 添加时间 /// </summary> public DateTime CreatTime { get; set; } public int PostId { get; set; } }
public class Post { /// <summary> /// 借书人 /// </summary> public int PostId { get; set; } /// <summary> /// 姓名 /// </summary> public string PostName { get; set; } /// <summary> /// 性别 /// </summary> public string Sex { get; set; } /// <summary> /// 住址 /// </summary> public string Address { get; set; } public List<Book> Books { get; set; } = new(); }标签:set,EFCore,get,int,外键,设置,public,string From: https://www.cnblogs.com/tlfe/p/18288249