Question: **UPDATED**: I understood I should not use a `DbSet` so I changed the implementation to an ICollection as suggested by Erenga

Please consider the following classes:

```
[Table("Tenant")]
public class Tenant : IEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    [Key]
    public string Guid { get; set; }
    public virtual ICollection<User> Users { get; set; }
}

[Table("User")]
public class User : IEntity
{
    public int Id { get; set; }

    public string Name { get; set; }
    public string EmailAddress { get; set; }
    public string Password { get; set; }
}

```

The first test creates a new Tenant and a new User and stores them in the appropriate tables.

```
    [Test]
    public void CreateNewUserForNewTenant()
    {
        var user = _applicationContext.Users.Create();
        user.Name = "barney";
        user.EmailAddress = "barney@flinstone.com";

        var tenant = _applicationContext.Tenants.Create();
        tenant.Name = "localhost";
        tenant.Guid = Guid.NewGuid().ToString();

        tenant.Users.Add(user); // NullReferenceException, I expected the EF would LazyLoad the reference to Users?!
        _tenantRepository.Add(tenant);
        _applicationContext.SaveChanges();
    }

```

This test will fail on a `NullReferenceException` since the property Users is not initialized. 

How should I change my code that I can rely on LazyLoading provided with EF?

Answer: 
There are 2 problems I see here.

1. As @SimonWhitehead mentioned, reference types are initialized as null by default. Lazy loading works only on entities created by EF. These are actually sub classes of your class that contain addtional logic to lazy load.
2. `DbSet` is not a collection type that is supported on entities. You need to change the type to `ICollection`, `ISet`, or `IList`.

Here's a working example

```
[Table("Tenant")]
public class Tenant : IEntity
{
    public int Id { get; set; }
    public string Name { get; set; }
    [Key]
    public string Guid { get; set; }
    public virtual ICollection<User> Users { get; set; }
}

[Table("User")]
public class User : IEntity
{
    public int Id { get; set; }

    public string Name { get; set; }
    public string EmailAddress { get; set; }
    public string Password { get; set; }
}

[Test]
public void CreateNewUserForNewTenant()
{
    var user = _applicationContext.Users.Create();
    user.Name = "barney"; 
    user.EmailAddress = "barney@flinstone.com";

    var tenant = _applicationContext.Tenents.Create();
    tenant.Name = "localhost";
    tenant.Guid = Guid.NewGuid().ToString();

    tenant.Users = new List<User> { user };
    _tenantRepository.Add(tenant);
    _applicationContext.SaveChanges();
}

```
I think you were expecting something like this (not threadsafe):

```
[Table("Tenant")]
public class Tenant : IEntity
{
    private DbSet<User> _users;

    public int Id { get; set; }
    public string Name { get; set; }
    [Key]
    public string Guid { get; set; }

    public virtual ICollection<User> Users 
    {
        get 
        {
            if (_users == null)
                _users = new List<Users>();

            return _users;
        }
        set { _users = value; }
    }
}

```

I'm sure the `Lazy<T>` class could be utilised somehow too but I am not familiar with that class.