4

I am trying to convert the project from here https://github.com/attilah/AngularJSAuthentication to using the mongo driver version 2 the latest one so I can adapt to my current project.

I nearly completed of my migration but I face with a few files which I dont know how to convert , because I new comming into the web api 2 and mongodb .

The problem which I am facing problem are:

  1. ApplicationIdentityContext.cs
  2. ApplicationUserManager.cs
  3. ApplicationRoleManager.cs

For example with ApplicationIdentityContext.cs I have tried as the following code, but does error appear and I get stuck on this point:

namespace AngularJSAuthentication.API
{
    using Entities;
    using Microsoft.AspNet.Identity.EntityFramework;
    using MongoDB.Driver;
    public class ApplicationIdentityContext : IdentityDbContext
    {
        public ApplicationIdentityContext(IMongoContext mongoContext)
            : this(mongoContext.Users, mongoContext.Roles)
        {
        }

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

        {
       } 
    }
}

and then the editor show me error when I build the program :

Severity Code Description Project File Line Suppression State Error CS1503 Argument 1: cannot convert from 'MongoDB.Driver.IMongoCollection<AngularJSAuthentication.API.Entities.User>' to 'System.Data.Common.DbConnection' AngularJSAuthentication.API D:\Projects\AngularJSAuthentication-master\AngularJSAuthentication.API\ApplicationIdentityContext.cs 14 Active

Here is my repos: https://github.com/skanel/Angular2-WebApi2-Mongodb2-Authentication

Do you have any idea?

tree em
  • 20,379
  • 30
  • 92
  • 130
  • This question looks like a possible duplicate to [this](http://stackoverflow.com/questions/38914303/identitycontext-could-not-be-found-are-you-missing-a-using-directive-or-an-as/39042599#39042599) I answered my two cents there. Care to have a look? – Swagata Prateek Aug 20 '16 at 00:44
  • https://github.com/skanel/Angular2-WebApi2-Mongodb2-Authentication – tree em Aug 20 '16 at 05:50

1 Answers1

4

Looks like it is a breaking change from 1.9 to 2.+. The package

AspNet.Identity.MongoDB is not compatible with the new mongo driver version 2+.

Hence the error: 'cannot convert from 'MongoDB.Driver.IMongoCollection<AngularJSAuthentication.API.Entities.User>' to 'System.Data.Common.DbConnection'

alltej
  • 6,787
  • 10
  • 46
  • 87