I'm working with EF Core 3.1 and i use sql server datatype hierarchyid on one of my tables.
When i scaffold the table into my project the 'hierarchyid' turns into Geometry type.
I tried manually changing into SqlHierarchyId type with the help of dotMorten.Microsoft.SqlServer.Types package.
Code in my API :
[HttpGet]
[Route("")]
public ActionResult<List<EntityDto>> Get()
{
EntityRepository repo = new EntityRepository (_context);
var reults = repo.GetAll().ToList(); // <-- fails here
return _mapper.Map<List<Entity>, List<EntityDto>>(reults);
}
GetAll() returns this :
protected DbSet<TEntity> dbSet;
public virtual IQueryable<TEntity> GetAll()
{
return dbSet;
}
But when I try to get the list of this entities i get an error :
Unable to cast object of type 'Microsoft.SqlServer.Types.SqlHierarchyId' to type 'Microsoft.Data.SqlClient.Server.IBinarySerialize'.
I didn't find any way to overcome this error.
Thanks for helping.