上下文:
我有关系
class Service {
public virtual int Sequencial { get; set; }
public virtual string Name { get; set; }
public virtual ServiceType Type { get; set; }
...
}
class ServiceType {
public virtual int Sequencial { get; set; }
public virtual string Name { get; set; }
}
在NHibernate类中看起来像这样
Id(s => s.Sequencial, “ SERVICE_ID”)。GeneratedBy.Sequence(“ SQ_SERVICE_ID”);
引用(s => s.ServiceType,“ SERVICE_TYPE_ID”);
地图(a => a.Nome,“ SERVICE_NAME”);
...
我如何实现 References(s => s.ServiceType,“ SERVICE_TYPE_ID”),换句话说,如何在EF中实现多对一?
答案 0 :(得分:0)
class Service {
public virtual int Sequencial { get; set; }
public virtual string Name { get; set; }
public virtual ServiceType Type { get; set; }
}
class ServiceType {
public virtual int Sequencial { get; set; }
public virtual string Name { get; set; }
public IList<Service> Services{get;set;}
}
使用这两个链接获得更多指导
asp
asp核心
https://www.entityframeworktutorial.net/efcore/one-to-many-conventions-entity-framework-core.aspx