我一直使用SQL表来引用静态数据,例如,在我的一个应用程序中,技术人员与客户表有一对多的关系。
基本上,我想在SQL中做的事情是这样的,所以我不是处理字符串,而是将it作为byte或tinyint处理,这在磁盘上占用的空间更小,因为客户端总是静态的,很少添加新的客户端。
| Technicians | | Clients | | ClientsRef |
| Id | | Id | ClientRefId | TechnicianId | | Id | Name |我的问题是在EF Core2.2中做到这一点,我如何创建这个静态数据?我读到过关于使用枚举的文章,但是之后如何在SQL Server中访问这些数据呢?
public class Technician
{
int Id { get;set; }
}
public class Client
{
int Id { get;set; }
int Technicianid { get; set; }
} 发布于 2019-05-27 02:35:44
这一点:
public class Technician
{
int Id { get;set; }
}
public class Client
{
int Id { get; set; }
int TechnicianId { get; set; }
public virtual Technician Technician {get; set;}
public string Name { get; set; }
}这应该就是你所需要的。模型中不需要任何其他表或键。
https://stackoverflow.com/questions/56314639
复制相似问题