0
I have 3 model
public class UnidadeNegocio
{
public int Id { get; set; }
public string Nome { get; set; }
}
public class Cliente
{
public int Id { get; set; }
public int UnidadeNegocioId { get; set; }
public string Nome { get; set;}
}
public class Venda
{
public int Id { get; set; }
public int ClienteId { get; set; }
public int UnidadeNegocioId { get; set; }
public float Valor{ get; set; }
}
I need to ensure that in the Customer and Sale table, both contain the same Business Unit Id. That is, they must be the same.
In Sql server, we create composite key
How I could create and solve this problem using Fluent Api
of Entity Framework?
Seeing thus the two tables Customer and Sale, the Customer 12 will always be a Unidadenegocioid = 1, so that play on the Sale table, there is no planning error ai no ?
– novic
@Virgilionovic this is an example, ID is always dynamic, so there is the table Unidadeneogicio
– Marcelo Dias
is a bad example, because if you carry the ID together that does not guarantee that I can change in the customer table? I mean, I believe this is a bad example.
– novic
@Virgilionovic is a visual example only, to have a value "1" as an example... It is not an example of code, but visual...
– Marcelo Dias
@Virgilionovic edited the question, removed the "example", can help?
– Marcelo Dias
Marcelo the table are the same. To do this you need a third table that contains a unique ID for Client 1 and Unidadenegocioid = 1 for example and in the Sales table bring this ID generated type Clientunidadenegocio with 3 fields Id, Clienteid and Unidadenegocioid ... maybe I would do so, depends on a context, but at first it would be this.
– novic