0
motaj1982 created
Hello! Could you help me?
I want an entity (table) with an integer primary key (Default like shown below), but I need the fields "GenericoId" and "VersaoId" like composite index unique.
How can I do that?
public class VersaoDado : FullAuditedEntity
{
public virtual Guid GenericoId { get; set; }
[ForeignKey("VersaoId")]
public virtual int VersaoId { get; set; }
public virtual Versao Versoes { get; set; }
}
1 Answer(s)
-
0
Look at entity framework Index attribute.
public class VersaoDado : FullAuditedEntity { [Index("IX_GenericoId_VersaoId", 1, IsUnique = true)] public virtual Guid GenericoId { get; set; } [Index("IX_GenericoId_VersaoId", 2, IsUnique = true)] [ForeignKey("VersaoId")] public virtual int VersaoId { get; set; } public virtual Versao Versoes { get; set; } }