I have two tables Customers and Country and use ( Entity Framework with vs 2012 )
And the model class
using System;
using System.Collections.Generic;
public partial class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string Email { get; set; }
public string Phone { get; set; }
public Nullable<int> CountrryId { get; set; }
public string Note { get; set; }
public virtual Country Country { get; set; }
}
I try to build a select query for get all customers with Country Name. But I always get the below error message.
using
after returnLazy Loading
might be enabled for your context, which meansCountry
is loaded from database using the parent context's connection when you first try to read its value by accessing that property.ToList
there butCountry
is not (even in model it'svirtual
where getter goes to db)