Symptoms

When attempting to use Entity Spaces with VistaDB 5, you can compile the Entity Spaces provider but when attempting a loadall() on any collection you get a MethodAccessException:

Attempt by method 'EntitySpaces.VistaDB5Provider.DataProvider.EntitySpaces.Interfaces.IDataProvider.esLoadDataTable(EntitySpaces.Interfaces.esDataRequest)' to access method 'EntitySpaces.VistaDB5Provider.QueryBuilder.PrepareCommand(EntitySpaces.Interfaces.esDataRequest)' failed.

Cause

VistaDB no longer supports medium trust as of version 5. The VistaDB 4 provider the source code for Entity Spaces is based on has an assemble attribute:

[assembly: AllowPartiallyTrustedCallers]

Resolution

Comment out the aforementioned line in the AssemblyInfo.cs file and recompile. But most importantly don't use the Entity Spaces MTLoader factory.