Relationship between entities returns null

1

I'm having trouble checking a parameter in a relationship between the Historian and Login entities.

public class Historico {
    public int ID { get; set; }
    public virtual Login login{ get; set; }
    public DateTime inicio { get; set; }
    public DateTime final { get; set; }
}

public abstract class Login
    {
        public int ID { get; set; }
        [Required]
        public string Nome { get; set; }
        private string Senha { get; set; }
    }

Because whenever I query the database, the Login field returns null. I would like to know what the modification has to be so I can return the login when accessing with the database.

    
asked by anonymous 26.10.2016 / 04:51

1 answer

1

Because it is a virtual parameter and the abstract class may be affecting its result.

  • Remove abstract from class.
  • When you have the virtual, if you are working with entity, you can use FluentApi ( link ) there you will have the user information.
  • 26.10.2016 / 07:36