# Exception when updating LoginCredential.Username after upgrade from 4.8 to 6.2.2

**URL:** <https://forum.litium.com/t/exception-when-updating-logincredential-username-after-upgrade-from-4-8-to-6-2-2/607>\
**Category:** Questions\
**Tags:** litium-6\
**Created:** [February 20, 2019, 9:32am UTC](https://forum.litium.com/t/exception-when-updating-logincredential-username-after-upgrade-from-4-8-to-6-2-2/607 "2019-02-20T09:32:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![krilin](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/krilin/32/175_2.png) [@krilin](https://forum.litium.com/u/krilin)\
**Post date:** [February 20, 2019, 9:32am UTC](https://forum.litium.com/t/exception-when-updating-logincredential-username-after-upgrade-from-4-8-to-6-2-2/607/1 "2019-02-20T09:32:51Z")

</div>

Hi!

After upgrade from 4.8 to 6.2.2 I cannot not update login credentials for existing users.

The following code:

var person = customerPerson.MakeWritableClone();  
person.LoginCredential.Username = string.IsNullOrEmpty(customerPerson.Email) ? customerPerson.Id : customerPerson.Email;  
person.LoginCredential.NewPassword = customerPerson.Id;  
\_personService.Update(person);

gives me:

Database operation expected to affect 1 row(s) but actually affected 0 row(s). Data may have been modified or deleted since entities were loaded. See [http://go.microsoft.com/fwlink/?LinkId=527962](http://go.microsoft.com/fwlink/?LinkId=527962) for information on understanding and handling optimistic concurrency exceptions.

vid Litium.Application.Data.LitiumDbContext.SaveChanges(Boolean acceptAllChangesOnSuccess)  
vid Litium.Application.Data.Batching.BatchDataImpl.Commit()  
vid Litium.Application.Customers.PersonServiceImpl.Update(Person person)  
vid Litium.Studio.Integration.Implementation.Imports.CustomerImportLogic.SetupCustomerUserAccount(Person customerPerson, Boolean shouldActivate, Boolean isNew) i D:\Projekt\Fresks\Development\Web\Src\Litium.Studio.Integration.Implementation\Imports\CustomerImportLogic.cs:rad 209  
vid Litium.Studio.Integration.Implementation.Imports.CustomerImportLogic.UpdateCustomer(Item item, Person customerPerson) i D:\Projekt\Fresks\Development\Web\Src\Litium.Studio.Integration.Implementation\Imports\CustomerImportLogic.cs:rad 198  
vid Litium.Studio.Integration.Implementation.Imports.CustomerImportLogic.CreateOrUpdateCustomer(Item item) i D:\Projekt\Fresks\Development\Web\Src\Litium.Studio.Integration.Implementation\Imports\CustomerImportLogic.cs:rad 164  
vid Litium.Studio.Integration.Implementation.Imports.CustomerImportLogic.ProcessItem(Item item) i D:\Projekt\Fresks\Development\Web\Src\Litium.Studio.Integration.Implementation\Imports\CustomerImportLogic.cs:rad 113

If I try to update login credentials from Litium backoffice I get “An error has occured”.  
I guess it is the same error as when I try to update from code.

Thanks!

/Kristoffer

Litium version: 6.2.2.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [February 20, 2019, 10:35am UTC](https://forum.litium.com/t/exception-when-updating-logincredential-username-after-upgrade-from-4-8-to-6-2-2/607/2 "2019-02-20T10:35:00Z")

</div>

Your coworker have a support ticket for the same case where we reply that the database upgrade need to be executed again on a database from the database backup because you have bad data in the `Foundation_User` table was throwing exception when you run the database script.

Before you rerun the database script on the restored database you need to remove the following row in the database that will cause the upgrade script exception.

```auto
Userid Login PwdDte Password
3C1C8503-7212-43A8-8803-AE725F7BAB2F	Authority	NULL	!Authority:

```
