Open p10tyr opened 9 years ago
I think I know why its getting the Person entity instead of ApplicationUser.
The entity that was returned useing FindByName, its ID is RavenUsers/peter@mail.com
I am a newb with RavenDB but I don't understand why the FindByID would get a result from the Persons table and then try and cast it to ApplicationUser?
I have been trying to get a user by their ID, using
UserManager
, which is an email address. For the sake of example peter@mail.comI also have a
Model.Person
, which I store in the same database as the RavenUsers, and the Key is also the same email.When I create the user I use this code
var user = new Models.ApplicationUser(userName);
(UserName is the Email)I have now eventually got got this working by using
var user2 = UserManager.FindByName("peter@mail.com");
The problem is when I use this
var user3 = UserManager.FindById("peter@mail.com");
I get an exception
Unable to cast object of type 'Models.Person' to type 'Models.ApplicationUser'.
I have been trying to work out what the problem is about 2 days now, on and off, but it seems when I use the
FinByID
, RavenDB, or Identidy.Raven DB for some reason actually matches up with the Person Key in the database. I couldn't understand why I was getting this exception the whole time since I am just calling a method and not trying to cast any thing.When I use
var user3 = UserManager.FindByEmail("peter@mail.com");
It reutrns NULL, even though in the database under ApplciationUsers, the Email is the same as UserName and the same as the Key.
Is this a Identity.RavenDB problem?