0
I have a question, I am programming with . NET MVC using the Entity Framework. At the moment I have:
class Produto
{
public int ProdutoId { get; set; }
public string Nome { get; set; }
public string Descricao { get; set; }
public virtual UsuarioSistema CadastradoPor { get; set; }
public virtual UsuarioVisitante CadastradoPor { get; set; }
}
The problem is: the 'Registered' field must have the FK of the User Entity OR Usersvisitor.
The User Entity System has many more attributes than the Visiting User Entity, so they are separate.
But even the Usersvisitor being simple and limited, it can also register a product. How should I do the relationship in the entity Product?
class UsuarioVisitante : Usuario
{
public virtual Fornecedor Fornecedor { get; set; }
public virtual ICollection<Produto> Produtos { get; set; }
}
You have a table for Usersystem and another for Usersvisitor?
– Leandro Angelo
That, a table User System, User and Product. I did not assemble together because Usuariosistema has many other attributes that are not necessary for Usuariovisitante.
– rafaelmacedo
I mean the same database... And in the Product table, you have a "Registered" column for system user and another for visiting user?
– Leandro Angelo
No, that’s the question. I didn’t want to make two columns, because the product will be registered by a Userssystem or Usersvisitor. Understand? The Registered column should receive a key Foreign from Userssystem or Usersvisitor.
– rafaelmacedo
And how will you know when a Registered is from one or the other
– Marco Souza