Microsoft.AspNet.Identity.EntityFramework.UserStore does not have a constructor that takes the parameters

0

I being a newbie working on app with MVC5 and EF 6. I am using dependency injection to resolve my classes. Everything was ok untill I changed the connection string and changed something(i dont know) in my dependency registering class that is unity config.

Now whenever i run it, it gives me this error. Microsoft.AspNet.Identity.EntityFramework.UserStore does not have a constructor that takes the parameters. I am using Unity nuget package manager

below is my code, any help would be appreciated

    using Microsoft.AspNet.Identity;
    using Microsoft.AspNet.Identity.EntityFramework;
    using Oxford.Core.Data;
    using Oxford.Data;
    using Oxford.Services;
    using OxfordLibrary.Models;
    using System.Web.Mvc;
    using Unity;
    using Unity.Injection;

    namespace OxfordLibrary.App_Start
    {
        public class UnityConfig
        {
            public static void RegisterComponents()
            {
                // Repository
                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(typeof(IRepository<>), typeof(EfRepository<>));

                container.RegisterType<ApplicationUserManager>();


                // Services

                container.RegisterType<IMasterService, MasterService>();

                // Resolve

                container.RegisterType<IUserStore<ApplicationUser>, UserStore<ApplicationUser>>(
                       new InjectionConstructor(typeof(ApplicationDbContext)));
            }
        }
    }

OxfordLibrary is name of my project Exception I am getting is : System.InvalidOperationException HResult=0x80131509 Message=The type Microsoft.AspNet.Identity.EntityFramework.UserStore`1[[OxfordLibrary.Models.ApplicationUser, OxfordLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] does not have a constructor that takes the parameters (ApplicationDbContext). Source=Unity.Abstractions StackTrace: at Unity.Injection.InjectionConstructor.ConstructorByType(Type typeToCreate, Type[] types) at Unity.Injection.InjectionConstructor.AddPolicies(Type serviceType, Type implementationType, String name, IPolicyList policies) at Unity.UnityContainer.RegisterType(Type typeFrom, Type typeTo, String name, LifetimeManager lifetimeManager, InjectionMember[] injectionMembers) at Unity.UnityContainerExtensions.RegisterType[TFrom,TTo](IUnityContainer container, InjectionMember[] injectionMembers) at OxfordLibrary.App_Start.UnityConfig.RegisterComponents() in D:\Programs\2018\OxfordLibrary\OxfordLibrary\App_Start\UnityConfig.cs:line 35 at OxfordLibrary.MvcApplication.Application_Start() in D:\Programs\2018\OxfordLibrary\OxfordLibrary\Global.asax.cs:line 20

asp.net-mvc
dependency-injection
entity-framework-6
asp.net-identity
unity-container
asked on Stack Overflow Jul 2, 2018 by Rajdeep • edited Jul 3, 2018 by Rajdeep

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0