public static void RegisterComponents() { var container = new UnityContainer(); // register all your components with the container here // it is NOT necessary to register your controllers // e.g. container.RegisterType<ITestService, TestService>(); container.RegisterInstance <IAuthService>(new AuthService()); container.RegisterType <IPersonRepository, PersonRepository>(); container.RegisterType <IDataBaseConnection, HoldRepository>(); DependencyFactory.SetFactory(() => container.Resolve <IAuthService>()); GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container); }