I have two classes:
- User > Contains your PK (ID).
- UsuarioP > Contains user ID (FK).
Class User.cs
public Usuario()
{
this.UsuariosP = new List<UsuarioP>();
}
public int Id { get; set; }
(...)
public virtual ICollection<UsuarioP> UsuariosP { get; set; }
Class User.cs
public partial class UsuarioP
{
public int Id { get; set; }
public Nullable<int> IdUsuario{ get; set; }
public string Login { get; set; }
(...)
public virtual Usuario Usuario{ get; set; }
}
The classes have been mapped like this.
I'd like to call the Login
that is inside UsuárioP
in Usuario
. I can not because of their relationship, otherwise I could.
Attempts - I have already created a virtual userP attribute within User. (Unsuccessfully) - I've tried to instantiate it this way:
public string login {get { return this.UsuarioP.Login} } (Sem sucesso)
- Putting
Login
intoUsuario.cs
as[NotMapped]
(Unsuccessful)
Important: I want to get the get and set of this attribute. My project is working with controllers , models , and views .
How do I call Login
within UsuarioP
so that I can use it on User screens?
Note: Working with MVC 4
EF 5
Fluent API