0

I'm facing problem with 'Unrecognized Guid format.' while trying to find the data in the set. Application work with .Net 4.5 and EF6. I'm facing this issue since we switch from MsSql to MySql Db.

Entities look like:

public abstract class DomainEntity(){
    public Guid Id { get; protected set; };
    public bool IsActive { get; protected set; }
    public DateTime CreateTime { get; set; }
    public DateTime ModifyTime { get; set; }
}

The DB tables look like:

CREATE TABLE IF NOT EXISTS `MssDocumentsDb`.`dbo_Versionings` (
`Id` CHAR(36) UNIQUE NOT NULL,
`IsActive` TINYINT(1) NOT NULL DEFAULT 1,
`CreateTime` DATETIME(6) NOT NULL,
`ModifyTime` DATETIME(6) NOT NULL,
PRIMARY KEY (`Id`));

And getting most data working properly, but sometimes I'm facing the issue with 'Unrecognized Guid format.'

The places where mostly that error occurs looks like:

public virtual TEntity Get(Guid Id)
        => Id != Guid.Empty ? GetSet().Find(Id) : null;

Create set:

public IDbSet<TEntity> CreateSet<TEntity>()
        where TEntity : class => base.Set<TEntity>();

I'm tried different solutions to solve this issue. Tried to switch Id in db from CHAR(36) to varchar(64), passing Id.ToSting() or adding 'Old Guids=true' to the connection string, but without results.

Thanks for any help.

2 Answers2

0

Many thanks to @mjwills for the help with figuring out what's going wrong.

My main issue was the data of Ids. Some Ids after migrating from MsSql to Mysql were imported as an empty string otherwise in mssql they were stored as null. After updating data for ids (set null where id = '') all work properly.

0

Check your entire row record if contains another guid columns which are empty. Sadly the error is not very informative, for example which column is empty but it is supposed to be a guid.

Zahari Kitanov
  • 510
  • 7
  • 15