I am getting the role being created but the description does not get updated.
I have tried in two ways:
First:
Roles.CreateRole(model.RoleName);
using (tgpwebgedEntities context = new tgpwebgedEntities())
{
var query = from r in context.aspnet_Roles where r.RoleName == r.RoleName select r;
var obj = query.First();
obj.Description = model.Description;
context.SaveChanges();
}
Second:
using(tgpwebgedEntities context = new tgpwebgedEntities()) {
var obj = context.aspnet_Roles.Single(r => r.RoleName == roleModel.RoleName);
obj.Description = roleModel.Description;
context.SaveChanges();
}
The curious thing is that this second way is the way I am using when the user is editing an aready created role using another action and works fine.
This first is used in a method that created the role and update its description since there is no support for description in .NET.
The problem is with your query statement,
“r.RoleName == r.RoleName” which will always be true and returns all entries. The query should be something similar to what you have in the second query