1

So I've implemented everything from this projects sample from github: http://www.tugberkugurlu.com/archive/aspnet-identity-ravendb--fully-asynchronous-new-and-sweet-asp-net-identity-implementation-for-ravendb

But I get an error in the file IdentityModels.cs

public class ApplicationUser : RavenUser
{
    public ApplicationUser(string userName)
        : base(userName) <--- here, explained below
    {
    }
}

The error says: Error 29 'AspNet.Identity.RavenDB.Entities.RavenUser' does not contain a constructor that takes 1 argument

But in Tugberk Ugurlus example-prject everything works fine. I don't know what I am missing. The ApplicationUser above witch inheritance from RavenUser, if I in the example project goes to the definition for RavenUser it leads me to this file:

public class RavenUser : IUser
{
    private List<RavenUserClaim> _claims;
    private List<RavenUserLogin> _logins;

    [JsonConstructor]
    public RavenUser(string userName)
    {
        if (userName == null) throw new ArgumentNullException("userName");

        Id = GenerateKey(userName);
        UserName = userName;
        _claims = new List<RavenUserClaim>();
        _logins = new List<RavenUserLogin>();
    }

    public RavenUser(string userName, string email) : this(userName)
    {
        Email = email;
    }

    public string Id { get; private set; }
    public string UserName { get; set; }
    public string Email { get; private set; }
    public string PhoneNumber { get; private set; }
    public string PasswordHash { get; private set; }
    public string SecurityStamp { get; private set; }
    public bool IsLockoutEnabled { get; private set; }
    public bool IsTwoFactorEnabled { get; private set; }

    public int AccessFailedCount { get; private set; }
    public DateTimeOffset? LockoutEndDate { get; private set; }

    public IEnumerable<RavenUserClaim> Claims
    {
        get
        {
            return _claims;
        }

        private set
        {
            if (_claims == null)
            {
                _claims = new List<RavenUserClaim>();
            }

            _claims.AddRange(value);
        }
    }
    public IEnumerable<RavenUserLogin> Logins
    {
        get
        {
            return _logins;
        }

        private set
        {
            if (_logins == null)
            {
                _logins = new List<RavenUserLogin>();
            }

            _logins.AddRange(value);
        }
    }

    public virtual void EnableTwoFactorAuthentication()
    {
        IsTwoFactorEnabled = true;
    }

    public virtual void DisableTwoFactorAuthentication()
    {
        IsTwoFactorEnabled = false;
    }

    public virtual void EnableLockout()
    {
        IsLockoutEnabled = true;
    }

    public virtual void DisableLockout()
    {
        IsLockoutEnabled = false;
    }

    public virtual void SetEmail(string email)
    {
        Email = email;
    }

    public virtual void SetPhoneNumber(string phoneNumber)
    {
        PhoneNumber = phoneNumber;
    }

    public virtual void SetPasswordHash(string passwordHash)
    {
        PasswordHash = passwordHash;
    }

    public virtual void SetSecurityStamp(string securityStamp)
    {
        SecurityStamp = securityStamp;
    }

    public virtual void IncrementAccessFailedCount()
    {
        AccessFailedCount++;
    }

    public virtual void ResetAccessFailedCount()
    {
        AccessFailedCount = 0;
    }

    public virtual void LockUntil(DateTimeOffset lockoutEndDate)
    {
        LockoutEndDate = lockoutEndDate;
    }

    public virtual void AddClaim(Claim claim)
    {
        if (claim == null)
        {
            throw new ArgumentNullException("claim");
        }

        AddClaim(new RavenUserClaim(claim));
    }

    public virtual void AddClaim(RavenUserClaim ravenUserClaim)
    {
        if (ravenUserClaim == null)
        {
            throw new ArgumentNullException("ravenUserClaim");
        }

        _claims.Add(ravenUserClaim);
    }

    public virtual void RemoveClaim(RavenUserClaim ravenUserClaim)
    {
        if (ravenUserClaim == null)
        {
            throw new ArgumentNullException("ravenUserClaim");
        }

        _claims.Remove(ravenUserClaim);
    }

    public virtual void AddLogin(RavenUserLogin ravenUserLogin)
    {
        if (ravenUserLogin == null)
        {
            throw new ArgumentNullException("ravenUserLogin");
        }

        _logins.Add(ravenUserLogin);
    }

    public virtual void RemoveLogin(RavenUserLogin ravenUserLogin)
    {
        if (ravenUserLogin == null)
        {
            throw new ArgumentNullException("ravenUserLogin");
        }

        _logins.Remove(ravenUserLogin);
    }

    // statics

    internal static string GenerateKey(string userName)
    {
        return string.Format(Constants.RavenUserKeyTemplate, userName);
    }
}

But in my own project the inheritance also is RavenUser. But if I go to that definition it leads me to this MetaData-file:

#region Assembly AspNet.Identity.RavenDB.dll, v1.0.1.0
//          C:\Users\Computer\Desktop\AppHarborRepository\Blog\packages\AspNet.Identity.RavenDB.1.0.1\lib\n    et45\AspNet.Identity.RavenDB.dll
#endregion

using System.Collections.Generic;

namespace AspNet.Identity.RavenDB.Entities
{
public class RavenUser : User
{
    public RavenUser();

    public ICollection<RavenUserClaim> Claims { get; set; }
    public ICollection<RavenUserLogin> Logins { get; set; }
}
}
user3228992
  • 1,373
  • 1
  • 16
  • 31
  • Are you sure you are using the latest pre release. I had a problem where it said it does not take 0 arguments. I am using Pre-6, came from 1.0.1 – Piotr Kula May 28 '15 at 11:22

1 Answers1

0

On first glance it looks like you have an incorrect "using" statement in your code that points to the AspNet.Identity.RavenDB RavenUser instead of your own implementation.

See if there is a "using AspNet.Identity.RavenDB.Entities" in your ApplicationUser class and remove it. If this breaks other parts of your code you might want to give your RavenUser class a different name.

Stitch10925
  • 172
  • 11
  • Nah.. that's not correct. We want to use the RavenUser class and that implementation. The newer pre release takes some new variable into the base constructor on RavenUser, actualyl quite a few things changed and the blog article is out of data. Need to look into the tests and sample – Piotr Kula May 28 '15 at 11:26