Feb 10, 2016 05:06 AM|superjose|LINK
Hello to all! This problem tend to happen to me sporadically. I still do not know the cause of the issue.
ASP.NET 4.6 with MVC 5 + EF 6.1 + Identity 2.2.1
I have a simple seed method for inserting an Admin account to it. As following the guides from the Internet, I end up doing the following:
var role = roleManager.FindByName(roleName);
if (role == null)
role = new AppRole(roleName);
var roleresult = roleManager.Create(role);
var user = userManager.FindByName(UserName);
if (user == null)
//Omitted code for brevety.
var result = userManager.Create(user, password);
//Keep doing some stuff.
Simple, right? The code which I've omitted is for filling in the details.
The problem is the following: Most of the times, when I run the seed method and it hits the roleManager.FindByName(roleName) the thread in which it was running exits (with code 0 (0x0)). The same goes on with userManager.FindByName. But, if I don't use those
methods, everything goes smoothly.
I have checked for values in the roleManager and it is not null (it would have shouted an object not reference...)
Not that is killing me, because I only use the Seed method once... But it intrigues me to what it could be causing it.
Thanks a lot!