none
CRM On-premises '[MyWorkflowsNamespace].Entities.BusinessUnit' is not a known entity type RRS feed

  • Question

  • I have Workflows and Entities project withing my VS solution. Entities.cs file under Entities project is auto generated using CrmSvcUtil.exe, containing early bounded entities.

    I need to have BusinessUnit, Organization and etc. types in my CodeActivity workflow.For this purpose I added Entities folder under Workflows project and within it Entities.cs file has been added as a link (tried also with adding Entities dll as reference - same result) and I have the following code:

    all needed using were added

    using (var dataContext = new CrmDataContext(service))
    {
    	BusinessUnit businessUnit = dataContext.BusinessUnitSet.Where(o => o.Id == businessUnitId).FirstOrDefault();
    
    	if (businessUnit != null)
    	{
    		Organization orgSetting = dataContext.OrganizationSet.Where(o => o.Id == businessUnit.OrganizationId.Id).FirstOrDefault();
    
    		if (orgSetting != null)
    		{
    		    //some logic here
    		}
    	}
    }

    Then on Workflows build ILMerge is merging all required components to the final dll.

    n CRM using my CodeActivity in custom workflow I have the following error:

    The specified type '[MyWorkflowsNamespace].Entities.BusinessUnit' is not a known entity type.Code

    I googled it and found that adding [assembly: Microsoft.Xrm.Sdk.Client.ProxyTypesAssemblyAttribute()] to AssemblyInfo should help, but it didn't.

    My guess is that somehow CrmDataContext is not being initialized correctly. But here my knowledge is limited and I don't know what to look for.
    Have any of you experienced this issue? What could possibly cause such?

    Wednesday, October 30, 2019 10:42 AM