Invalid Entity Exception

When I run my app I get

Project GASphinx.exe raised exception class EInvalidEntity with message 'Class TJob is not a valid Entity. [Entity] attribute missing or entity does not belong to model.'.

The definition of TJob is

  [EntityAuthorizeScopes(SCOPE_ALL_USERS, EntitySetPermissionsAll)]
  TJob = class(TSMXBaseEntity)

I have another class which doesn't cause this exception (below) . Any ideas?

  [Sequence('SEQ_ORGANISATION', 1000, 1)]
  TGiftAidOrganisation = class(TSMXBaseEntity)

Have you added the correct units to your uses clause? Are you getting any warnings from the compiler?

It would be also recommended (although not mandatory) that you put your business classes in a model different than the one from Sphinx.

Yes, I think they are all there, they are the same as the class that works.

I'm not getting any warnings from the compiler, it's just when the app runs.

I have to get to grips with Models I think. When I have the TJob in the default model I have issues when it is called from one of the services.

Yep, maybe there is something more convoluted there with your model system and usage.

If you can reduce it to a minimal project reproducing the issue, we can tell better what's going on. Maybe in the process you will find out the issue yourself - that happens often. ;-)

I'll try, but no promises :slight_smile:

Just trying to get my head around multi model. If I need to access the Sphinx Model from a Service created on the Business Model, I would need the Sphinx.Manager and the Business.Manager? How would I get the right contexts?

The Sphinx manager and context already uses the Sphinx model implicitly, of course.

Missing RegisterEntity(TJob) ?

That was there, so it wasn't that.

Actually if it wasn't there, I don't think I'd have got the error as Aurelius wouldn't have known about it.