I am trying to setup Unity for the first time in a WebApi project. I have added Unity.WebApi from Nuget and my UnityConfig file looks like this.
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.RegisterType<ApplicationDbContext>(
new InjectionFactory(c => new ApplicationDbContext()));
//container.RegisterType<ApplicationSignInManager>();
container.RegisterType<ApplicationUserManager>();
GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
}
However, if I try and call one of the default controllers, Account/Register I get an error saying ensure that I have a parameterless constructor.
I have looked at various articles that explain that the way Unity works in MVC and WebApi but as far as I can tell my config is correct? Im guessing Im missing something simple here as my installation works perfectly for constructor injection in an MVC project.