Hi, I expect this to work because this is what the CRM does but FXE returns `InvalidEntityKeyOperation` instead. ``` [TestClass] public class RetrieveByAlternateKeyTests { [TestMethod] public void Retrieve_UnknownAlternateKey_ThrowsErrorCode() { // Arrange var context = MiddlewareBuilder .New() .AddCrud() .AddFakeMessageExecutors() .AddGenericFakeMessageExecutors() .AddPipelineSimulation() .UsePipelineSimulation() .UseMessages() .SetLicense(FakeXrmEasyLicense.Commercial) .Build(); context.EnableProxyTypes(typeof(Account).Assembly); context.InitializeMetadata(typeof(Account).Assembly); void AddAlternateKey(string entityLogicalName, params string[] keyAttributes) { var metadata = context.GetEntityMetadataByName(entityLogicalName); metadata.SetSealedPropertyValue(nameof(metadata.Keys), new EntityKeyMetadata[] { new() { KeyAttributes = keyAttributes } }); context.SetEntityMetadata(metadata); } AddAlternateKey(Account.EntityLogicalName, Account.Fields.AccountNumber); var service = context.GetOrganizationService(); // Act + Assert var exception = Assert.Throws<FaultException<OrganizationServiceFault>>(() => { service.Execute(new RetrieveRequest() { Target = new EntityReference(Account.EntityLogicalName, Account.Fields.AccountNumber, "something"), ColumnSet = new ColumnSet(false), }); }); Assert.AreEqual(ErrorCodes.RecordNotFoundByEntityKey, (ErrorCodes)exception.Detail.ErrorCode); } } ```
Activity
jordimontana82 commentedon Sep 18, 2026
Thanks Sven, I'll investigate for the next minor release.