Web api 2 and Mongodb v2 Porting sample code to use version 2

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

I almost finished my migration, but I come across several files that I cannot convert, because I start working in web api 2 and mongodb.

The problem I am facing is this:

  • ApplicationIdentityContext.cs
  • ApplicationUserManager.cs
  • ApplicationRoleManager.cs

For example, with ApplicationIdentityContext.cs I tried to use the following code, but an error appears and I was stuck at 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 will show me an error when creating 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

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

?

+4
1

, 1.9 2.+.

AspNet.Identity.MongoDB mongo 2 +.

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

+4

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


All Articles