"IdentityContext" could not be found (you are missing a using directive or assembly references)

I am migrating the project https://github.com/attilah/AngularJSAuthentication to use the mongodb verson 2 driver, and I am in the last step here:

namespace AngularJSAuthentication.API
{
    using AspNet.Identity.MongoDB;
    using Entities;
    using MongoDB.Driver;

    public class ApplicationIdentityContext : IdentityContext
    {
        public ApplicationIdentityContext(IMongoContext mongoContext)
            : this(mongoContext.Users, mongoContext.Roles)
        {
        }

        public ApplicationIdentityContext(IMongoCollection<User> users, IMongoCollection<Role> roles)
            : base(users, roles)

        {
        }
    }
}

Then i get this error

Severity Code Description Project File Line Suppression State Error CS0246 The type or namespace name 'IdentityContext' could not be found (are you missing a using directive or an assembly reference?) AngularJSAuthentication.API D:\Projects\AngularJSAuthentication-master\AngularJSAuthentication.API\ApplicationIdentityContext.cs

Here is my current source code

https://github.com/skanel/Angular2-WebApi2-Mongodb2-Authentication

UPDATED

@Swagata Prateek, thanks for your code, however, when I started It, stop working directly in this code block in startup.cs

private void ConfigureOAuth(IAppBuilder app, IContainer container)
        {
            var OAuthServerOptions = new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp = true,
                TokenEndpointPath = new PathString("/token"),
                AccessTokenExpireTimeSpan = TimeSpan.FromMinutes(30),
                Provider = container.Resolve<IOAuthAuthorizationServerProvider>(),
                RefreshTokenProvider = container.Resolve<IAuthenticationTokenProvider>()
            };

Error

An exception of type 'Autofac.Core.DependencyResolutionException' occurred in Autofac.dll but was not processed in user code

: . . . : Activator = SimpleAuthorizationServerProvider (ReflectionActivator), Services = [Microsoft.Owin.Security.OAuth.IOAuthAuthorizationServerProvider], Lifetime = Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, = OwnedByLifetimeScope

0
2

Identity Asp.net Mongodb , - , , Identity mongodb , .

, , , , , , . , Identity Asp.net Mongodb.

Update

  • , Attila Hajdrik git, , AspNet.Identity.MongoDB, . ​​, , nuget, , github . AspNet.Identity.MongoDB, . .

  • , , github-. IAccountContext, UserManager<User> AccountManager UserStore<User> . User class - Identity, Im, IdentityUser.

,    .

AccountContext:

public class AccountContext : IAccountContext
{        
    private readonly IDbContext dbContext;
    private readonly AccountManager accountManager;

    public AccountContext(
        IDbContext dbContext,         
        AccountManager accoutnManager)
    {
        this.dbContext = dbContext;
        this.accountManager = accoutnManager;        
    }
// Your own stuff here
}

AccountManager UserManager<T>, IUserStore<User>. , Identity.:)

, .

+1

. , .

, FYI, IdentityContext / AspNet.Identity.MongoDb. . Github: https://github.com/g0t4/aspnet-identity-mongo

0

Source: https://habr.com/ru/post/1651359/


All Articles