// Not used but CreateUser direct to database
        private void CreateUserRowByDatabase(MySqlSecurityDbContext db, string userName, IDictionary<string, object> values)
        {
            var newUserProfile = new UserProfile
            {
                UserName = userName,
            };
            int rows = -1;

            using (TransactionScope scope = new TransactionScope())
            {
                db.UserProfiles.Add(newUserProfile);
                rows = db.SaveChanges();

                if (values != null && values.Count > 0)
                {
                    var user = db.UserProfiles
                        .OrderByDescending(x => x.UserName)
                        .First(x => x.UserName == userName);
                    StringBuilder sql = new StringBuilder("UPDATE UserProfile SET ");

                    foreach (var key in values.Keys)
                    {
                        object value = values[key];

                        if (value == null)
                            continue;

                        if (value is String)
                            sql.AppendFormat("{0} = '{1}' ,", key, value);
                        else
                            sql.AppendFormat("{0} = {1} ,", key, value);
                    }

                    string sqlCommand = string.Format("{0} WHERE UserId = {1}", sql.ToString(0, sql.Length - 1), user.UserId);
                    rows += db.Database.ExecuteSqlCommand(sqlCommand);
                }

                scope.Complete();
            }

            if (rows == 0)
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.ProviderError);
            }
        }
        private void CreateUserRow(MySqlSecurityDbContext db, string userName, IDictionary<string, object> values)
        {
            var newUserProfile = new UserProfile
            {
                UserName = userName,
            };

            if (values != null && values.Count > 0)
            {
                var type = Type.GetType(ConfigUtil.MySqlSecurityInheritedContextType, false, true);
                var contextAssembly = Assembly.GetAssembly(type);
                var userProfileExType = contextAssembly.GetTypes().FirstOrDefault(x => x.BaseType == typeof(MySql.Web.Security.UserProfile));

                if (userProfileExType != null)
                {
                    object userProfileEx = Activator.CreateInstance(userProfileExType);
                    var userNamePi = userProfileEx.GetType().GetProperty("UserName");

                    userNamePi.SetValue(userProfileEx, userName);

                    foreach (var key in values.Keys)
                    {
                        var pi = userProfileExType.GetProperty(key);

                        if (pi != null && pi.CanWrite == true)
                        {
                            object value = values[key];

                            if (value == null)
                                value = DBNull.Value;

                            pi.SetValue(userProfileEx, value);
                        }
                    }

                    var userProfileExDbSet = EntryBy(db, userProfileExType.FullName);	// get DbSet<UserProfile inherited class>
                    var addMethod = userProfileExDbSet.GetType().GetMethod("Add");		// get Add method info
                    addMethod.Invoke(userProfileExDbSet, new object[] { userProfileEx });		// invoke add UserProfile inherited class object
                }
            }
            else
                db.UserProfiles.Add(newUserProfile);

            int rows = db.SaveChanges();

            if (rows != 1)
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.ProviderError);
            }
        }