I have a problem with a particular state machine not persisting the current state. I am using Entity Framework.
When debugging the instance inline, I can see that the state field on the instance is updated as expected.
But when the code leaves the state machine, the state at that time is not persisted to the database.
- Is there any special limitations or potential problems I should be aware of here, and how should I go about debugging this most efficiently?
- How about deletion of instances? Are instances that are "Finalized" not deleted? Can I safely delete them, and initialize new ones with the same ID later on if need be?
The transaction type is serialized.
During(Approving,
When(MatchesDecided, and => and.Data.HasNoConfirmedMatches())
.TransitionTo(Resolving)
.Then(b => DecideIdentity(b, new NewIdentityFromCaseDecision(b.Data.CaseId))),
When(MatchesDecided, b => b.Data.HasConfirmedMatches())
.TransitionTo(Resolving)))).Then(SEND A MESSAGE - OMITTED);
During(Resolving,
When(IdentityDecided)
.Then(PersistIdentityDecisison)
.ThenAsync(async context => await context.Publish(new RegistrationBiometryProcessedEvent(context.Data, context.Instance)))
.TransitionTo(Archived));
WhenEnter(Archived, b => b.Finalize());
The problem in this code is that the state is never set to "Archived" or "Final". The code actually executes, but nothing is persisted.