I'm migrating a project from EF6 to EF-Core. The Metadata API has changed significantly and I am unable to find a solution to this:
Under EF6 I could find the POCO Type from the Proxy Type using:
ObjectContext.GetObjectType(theEntity.GetType)
This, however, does not work under EF-Core (no ObjectContext
class). I've searched and searched to no avail. Does anyone know how to get the POCO type from either the entity
or the entity proxy type
?
There is no perfect way. You could for example check the namespace. If it's a proxy it'll
private Type Unproxy(Type type)
{
if(type.Namespace == "Castle.Proxies")
{
return type.BaseType;
}
return type;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With