LeoB wrote:
Presumably the adapter will only have the .Keys populated after I've populated it the first time?
new DataAccessAdapter().CatalogNameOverwrites.Keys
This is an empty dictionary for me when trying to get the original catalogs.
Yes, I think Walaa assumed you defined the overwrites somewhere e.g. a config file (as you know the new names too, so the old names should be available there too).
I'm happy to use the GetElementMappingInfo iteration, but alternatively is there a recommended way to make changes to the persistenceInfoProvider.lpt file? I can't see a TemplateID in the documentation to add to my project config. In the meantime I've added a HashSet<string> to the PersistenceInfoProviderCore object in the template file:
myCatalogStrings.Add(@"<%=mapping.MappedTarget.ContainingSchema.ParentCatalog.CatalogName%>");
This does the job but I'm not sure it's a long-term solution.
Altering the shipped template isn't really recommended. If you want the catalog names in the mappings, I'd go for an adhoc template (https://www.llblgen.com/Documentation/5.7/Designer/Functionality%20Reference/AdHocTemplates.htm) which is a separate simple template that's run every time you generate code and which generates e.g. a static class with C# code that produces the catalog names in a list or dictionary.
Enumerating the mapped catalogs in the project elements, you can either enumerate all mappings in a foreach loop and emit the catalog names there (just borrow code from the persistence info provider template) or simply ask the project what catalogs have elements in them using this method:
https://www.llblgen.com/Documentation/5.7/ReferenceManuals/Designer/html/CB8F8344.htm
There might be catalogs without mapped elements on them in that list, which might not be what you need.
In all honesty, I'd go for the meta-data retrieval as you had it, you need to it just once (as the data is static) and I doubt you'll notice the enumeration, even if your project has 1000s of entities. It frees you from the template adjustments and will work always.