Generic Entity Metadata Refactoring

This topic contains below mentioned sub-topics that describe GE metadata refactoring changes, its advantages and how to run the Metadata Verifier console application before upgrading to Aptify release 7.0.


Generic Entity (GE) Metadata Refactoring Changes
Until Aptify 6.4, an instance of the Generic Entity (GE) consumed too much memory. This is because each GE gets its own copy of the metadata structure. This metadata is duplicated within subtypes (since they are also GEs) and at the field level. Everyone getting their own instance does not make sense when the data structures are immutable. Singletons are a better option to be used instead. This significantly reduces the amount of memory consumed by GEs.
 
To tackle this issue, breaking changes were made to Metadata.dll. It is not backwards compatible with earlier versions of Aptify. You cannot use Metadata.dll 7.0.0.0 with earlier versioned systems. The assembly version has been incremented to 7.0.0.0 to account for this change. These changes were made to improve the memory performance of Aptify based applications. Generic entities should now consume significantly less memory.
 
We expect impact to customers to be rare, as internally Aptify only had to update about a dozen lines of code as a result of this break. Fixing errors should be obvious, as the breaking changes will result in compile time errors. Also, when discussing this breaking change with the developer community we did not hear from any customers who relied heavily on this functionality. If your implementation does rely on iterating the metadata properties and you are unclear of what new methods to call, reach out to Aptify support.

Technical note
The primary breaking change is removal of the ReadDataRow abstraction from the inheritance hierarchy of all classes in the Metadata.dll assembly. ReadDataRow allowed callers to mutate the internal representation of the metadata object's contents, which meant these objects were not true singletons and everyone had to obtain their own copy. Going forward there is only one instance of all the metadata abstractions. Additionally, some types are no longer enumerable because they should not have been enumerable to begin with. For example, EntityBaseViewFieldMetaData is the representation for a single base view field but could also be used to iterate over all fields on the base view. In these cases, all code has been updated to return the correct List type for the object in question. For example, instead of iterating on EntityBaseViewFieldMetaData you now iterate on EntityBaseViewFieldMetaDataList. Additionally, the methods, RemoveEntityLevelMetadataCacheItem(string) and ClearEntityLevelMetadataCache have also been removed from AptifyApplication, as AptifyApplication no longer uses its own cached copy of metadata, and instead relies on Metadata.dll's MetadataSingleton which has had its caching logic improved.
 
   Metadata Verifier console app
 To find any potential problem with the recent changes to the Metadata.dll assembly, the Metadata Verifier console application must be used before upgrading to Aptify 7.0. It is designed to be run twice, once with version 4.0.0.0 (File version 6.2.0.0) of the Metadata.dll assembly and then with the version 7.0.0.0.
Please follow the steps below:

  1. Copy the MetadataVerifier.exe and MetadataVerifier.exe.config file from the "Utilities > MetadataVerifier" folder available in the Core Database Setup folder of the extracted Aptify 7.0 setup
  2. Paste them into the Program Files > Aptify 5.0 folder which contains the Metadata assembly (Metadata.dll) from the Aptify 6.4 release, File version 6.2.0.0 (Assembly version 4.0.0.0).
  3. Open MetadataVerifier.exe.config file in a text editor.
  4. Update Server and SQL login details.
  5. Uncomment the dependentAssembly section in the MetadataVerifier.exe.config file as below
    .
  6. Save the MetadataVerifier.exe.config file.
  7. Run the MetadataVerifier.exe
  8. It generates three files namelyCultureStringMetadataSingleton-4.0.0.0[XXX].txt, CountryMetadataSingleton-4.0.0.0[XXX].txt and MetadataSingleton-4.0.0.0[XXX].txt, where [XXX] stands for the timestamp.
  9. Close the MetadataVerifier console application.
  10. Take a backup of the Metadata.dll version 4.0.0.0 (File version 6.2.0.0) from step two in a safe location.
  11. Replace the Metadata.dll assembly (File version 6.2.0.0) from the Aptify 5.0 folder with the version 7.0.0.0 assembly. This assembly can be found in the same location as step one.
  12. Comment the dependentAssembly section in the MetadataVerifier.exe.config file as shown in the image below.
  13. Re-run the MetadataVerifier.exe application.
  14. It generates three files namely
    • CultureStringMetadataSingleton-7.0.0.0[XXX].txt,
    • CountryMetadataSingleton-7.0.0.0[XXX].txt and
    • MetadataSingleton-7.0.0.0[XXX].txt, where [XXX] stands for the timestamp.
  15. Close the application.
  16. Replace the Metadata.dll version 7.0.0.0 with the same Metadata.dll (File version 6.2.0.0) from step 10.
  17. Compare the below files using comparison tools like WinMerge, BeyondCompare and so on. In case of discrepancies, get help from Aptify support.
    • Compare CultureStringMetadataSingleton-4.0.0.0[XXX].txt and CultureStringMetadataSingleton-7.0.0.0[XXX].txt
    • Compare MetadataSingleton-4.0.0.0[XXX].txt and MetadataSingleton-7.0.0.0[XXX].txt
    • Compare CountryMetadataSingleton-4.0.0.0[XXX].txt and CountryMetadataSingleton-7.0.0.0[XXX].txt