0
Good afternoon,
How do I map composite key in my entities, in case 1 entity calls document and its PK is by the property ID and WEBID, and it does FK with the User as I would in that case?
Document
public class Documento : IAggregate
{
[Key]
[Column(Order = 1)]
public int Id { get; set; }
[Key]
[Column(Order = 2)]
public int WebId{ get; set; }
public int UsuarioId { get; set; }
public string Situacao { get; set; }
public string Numero { get; set; }
public string Enviadoar { get; set; }
public DateTime DataCriacao { get; set; }
public virtual Usuario Usuario { get; set; }
}
User:
public class Usuario : IAggregate
{
[Key]
public int UsuarioId { get; set; }
public string CodigoUsuario { get; set; }
[Key]
public int WebId{ get; set; }
public string Codigo { get; set; }
public int NumeracaoAtual { get; set; }
public DateTime Ano { get; set; }
public virtual ICollection<Documento> Documentos { get; set; }
}
Possible duplicate of How to create composite key with Entity Framework 6
– Andre Mesquita
The question is the same, my entity is in the same way but the error persists so I posted here, the error that occurs is: Unable to determine Composite Primary key Ordering for type 'Teste.domain.Model.Documento'. Use the Columnattribute (see http://go.microsoft.com/fwlink/?Linkid=386388) or the Haskey method (see http://go.microsoft.com/fwlink/?Linkid=386387) to specify an order for Composite Primary Keys.
– Stand Alone