【发布时间】:2012-01-15 01:16:15
【问题描述】:
我遇到以下情况,我将 EF 与 IDbSet 实体一起使用,并且我的属性有一个 GUID 作为 PK,但我需要一个拥有自动增量的实体。如果我把key属性放在应该是auto-increment的属性上,属性就不再是GUID PK了。
有谁知道在不开启 PK 的情况下将自动增量属性放入 EF 的任何方法?
namespace Service.Entity.Order
{
[Serializable]
public class Order : IEntity
{
#region Properties
public Guid Id { get; set; }
public DateTime DateImplementation { get; set; }
public DateTime? DateDelivery { get; set; }
//Field Auto-Increment
public int NrOrder { get; set; }
#endregion
#region Status
public int ProcessStatus { get; set; }
public Status Created { get; set; }
public Status Approved { get; set; }
public Status PolicyDefined { get; set; }
#endregion
#region RelationShips
public Client Client { get; set; }
public User User { get; set; }
public Representation Representation { get; set; }
public Contact Contact { get; set; }
#endregion
}
}
【问题讨论】:
标签: entity-framework auto-increment