0

This is my applicationDbContext class:

   public class ApplicationDbContext : IdentityDbContext<ApplicationUser, CustomRole,
int, CustomUserLogin, CustomUserRole, CustomUserClaim>

and this is my controller action method to retreive all the users with their user name:

   public JsonResult GetUsers()
    {
        var ret = (from user in db.Users
                   orderby user.Id
                   select new
                   {
                       UserName = user.UserName,
                   }).AsEnumerable();
        return Json(ret, JsonRequestBehavior.AllowGet);
    }

Now, i am running into a problem.Whenever i execute, i got this problem----Multiple object sets per type are not supported. The object sets 'ApplicationUsers' and 'Users' can both contain instances of type 'App.Models.ApplicationUser'.

I have seen this so questions How to obtain a list of Users from ASP.NET Identity?. What is the simplest approach to solve this error.Should i follow the solution given in above question. i have already customized my user id property from string to int.

Community
  • 1
  • 1
duke
  • 1,816
  • 2
  • 18
  • 32
  • Everything was running fine before but once i tried the above code, it started giving me multiple objects sets Error. Strange thing is that i have removed the above code but still the same error.how is it possible – duke Dec 02 '15 at 13:45

1 Answers1

0

I guess you have added this to your ApplicationDbContext:

public DbSet<ApplicationUser> ApplicationUsers { get; set; } 

while through inheritance you already have it in IdentityDbContext:

public IDbSet<ApplicationUser> Users { get; set; }

Simply remove the ApplicationUsers and it will work

Łukasz Trzewik
  • 1,165
  • 2
  • 11
  • 26