'OData with Excel: We were unable to resolve the type name '' to an EdmType
I'm developing a web API for OData, but get a strange issue when retrieving the data in Excel.
I have /odata/books and /odata/presses from a demo I found, and /odata/cats, which is the one I added following the same format as the other controllers, DbSets etc.
In Excel, books and presses retrieve data without any problem, but when connecting to cats I get the following:

My model is as follows:
public class Cat
{
public int Id { get; set; }
public string Name { get; set; }
}
My controller is as follows:
public class CatsController : ODataController
{
private BookStoreContext _db;
public CatsController(BookStoreContext context)
{
_db = context;
if (context.Cats.Count() == 0)
{
foreach (var b in DataSource.GetCats())
{
context.Cats.Add(b);
}
context.SaveChanges();
}
}
[EnableQuery]
public IActionResult Get()
{
return Ok(_db.Cats);
}
}
My EdmModel is as follows:
private static IEdmModel GetEdmModel()
{
ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet<Cat>("Cats");
builder.EntitySet<Book>("Books");
builder.EntitySet<Press>("Presses");
return builder.GetEdmModel();
}
How do I fix this?
Solution 1:[1]
Per my answer on a similar question here...
After hours of struggling with the same "We were unable to resolve the type name '[EntityName]' to an EdmType", I found that Excel's Power Query seems to cache OData metadata. All you need to do to refresh it is click the Refresh Preview button on the Home tab of the ribbon then the error goes away.
Solution 2:[2]
Did you get this message in PowerBI? I was just fighting with the same issue: in Chrome/Edge etc. my OData feed just worked fine, in PowerBI I got this (strange) error message.
Just literally a few minutes ago, I found a solution for in PowerBI. When connect to an OData feed, you need to click 'advanced' and that also check the 'Include open type columns'. For me that seems to work so far.

Solution 3:[3]
Are you using OData V4? Does using OData V2 solve this? For some reason, PowerBI seems to have an issue with some V4 OData feeds that Excel's Power Query can handle without issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Digiwise |
| Solution 2 | Rob van Meeuwen |
| Solution 3 | Community |
