We were receiving the following errors, depending on how we got into the code:
1) Error loading entity relations
2) Type conflict: the DefaultManager is currently of type EntityManager
3) Type Deal must inherit from Entity does not
In our Deal class, I had implemented a static Create method:
public static Deal Create(User user)
{
Deal deal = _manager.CreateEntity<Deal>();
GetATemporaryKey(deal);
InitializeDefaults(deal, user);
AddToManager(deal);
InitializeChildren(deal, user);
return deal;
}
which used a static private EntityManager which was declared like this:
static DomainModelEntityManager _manager = DomainModelEntityManager.DefaultManager;
It turns out that at run time, this is actually initialized to an EntityManager, NOT a DomainModelEntityManager as I had expected.
I created a new LocalEntityManager class like this:
public static class LocalEntityManager
{
private static DomainModelEntityManager _em;
public static DomainModelEntityManager DefaultManager
{
get
{
if (_em == null)
_em = new DomainModelEntityManager();
return _em;
}
}
}
and changed the declaration in Deal like this:
static DomainModelEntityManager _manager = LocalEntityManager.DefaultManager;
Now, it all works like a charm.
[It only took 2 days to find this...]
|