F
F
fan92rus2019-08-03 07:25:14
C++ / C#
fan92rus, 2019-08-03 07:25:14

Why is EF core not receiving data?

Here are the models:

[Table("Accounts")]
public class Account
{
  [Key]
  public int Id { get; set; }
  public string Name { get; set; }
  public string Login { get; set; }
  public List<Element> Elements { get; set; }
}

[Table("Elements")]
public class Element
{
  [Key]
  public int Id { get; set; }
  public int AccountId { get; set; }
  public Account Account { get; set; }
  public string Name { get; set; }
}

When writing, everything is OK, the table is created and everything is added there.
But when fetching, the references are null.
var testAcc = dba.Data.Where(a => a.Login == "Test").Include(a => a.Elements).ToList().First();

Logger output:
5d4531e8111f1058437216.png
As a result, it turned out that Include is in two namespaces .. and the wrong one was connected ..
needed - using Microsoft.EntityFrameworkCore;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question