title: using ninject to inject dependency to The Model classes or non-controller classes
body: <p>I using Ninject 3 in Repository pattern in mvc 3 (steven sanderson Scaffolder).<br>
  and in ninject i have the class "NinjectWebCommon" which in the "RegisterServices" method i resolved the dependencies and i think im ready to go.  </p>
  
  <pre><code>  private static void RegisterServices(IKernel kernel)
    {
       kernel.Bind&lt;ICityRepository&gt;().To&lt;CityRepository&gt;();
       kernel.Bind&lt;IVillageRepository &gt;().To&lt;VillageRepository&gt;();
    }
  </code></pre>
  
  <p>i using my repositories in controllers using constructor injection and everything is fine.  </p>
  
  <pre><code>public class CityController : Controller
  {
     private readonly ICityRepository cityRepository;
  
     // If you are using Dependency Injection, you can delete the following constructor
     //public CityController() : this(new CityRepository())
     //{
     //}
  
     public CityController(ICityRepository cityRepository)
     {
        this.cityRepository = cityRepository;
     }
  
    // .........
  }
  </code></pre>
  
  <p>but when i use this repositories in other classes like Model(Entity) classes using property injection or field injection the dependency doesn't resolved and i get null reference exception on my Property or field.  </p>
  
  <pre><code>[MetadataType(typeof(CityMetadata))]
  public partial class City : IValidatableObject
  {
     [Inject]
     public IVillageRepository VillageRepo { get; set; }
  
     public IEnumerable&lt;ValidationResult&gt; Validate(ValidationContext validationContext)
     {
        var village = VillageRepo.Find(5); // will throw null reference exception on "VillageRepo"
     }
  }
  
  public partial class CityMetadata
  {
     [ScaffoldColumn(false)]
     public int ID { get; set; }
  
     [Required(ErrorMessage = MetadataErrorMessages.Required)]
     [StringLength(50, ErrorMessage = MetadataErrorMessages.ExceedMaxLength)]
     public string Name { get; set; }
  }
  </code></pre>
  
  <p>i don't know why this happening. so whats the problem and how can i use the repositories in non-controller classes?<br>
  thanks in advance.  </p>