I know that compiling the application (“Compile”) has to be performed before compiling the generated AX pcode to CIL (“CIL”). But what about synchronizing the database (“Synchronize”)?
I am confused because have found all of the following:
The book ‘Microsoft Dynamics AX 2012 R2 Administration Cookbook’ (page 74) has Synchronize, Compile, CIL.
So if all 3 are being done, where in the sequence should synchronize be: first, second, or last?
PS: I would think that the database would need to be synchronized first, to ensure that the compile is working with the correct information. But 2 out of the 3 above indicate that’s not the case.
CIL must be run after X++ compilation, because it depends on information provided by X++ compiler. The synchronization, on the other hand, generally depends on metadata, not code. There is no problem if a table isn’t and can’t be compiled, because it’s not executed by synchronization. I don’t think there is anything what would depend on compilation, except a little piece of code starting synchronization. Nevertheless if you’re building a new environment or you did a major change (e.g. installing a new model), I wouldn’t consider the environment ready for anything unless it’s fully compiled. Therefore I always run synchronization after compilation.
CIL generation and DB synchronization are not related at all, therefore their order doesn’t matter.
Re your PS: The compiler doesn’t read anything from the transaction database. It uses AOD files (in older versions) or the modelstore database (which is not touched by Synchronize).
“The compiler doesn’t read anything from the transaction database. It uses AOD files (in older versions) or the modelstore database (which is not touched by Synchronize).”
Okay, I guess I’m not clear on what synchronization does, other than the vague “it syncs up the SQL Server database with the AOT”.
Even though synchronize includes syncing up IDs of elements in the AOT (IDs of tables and fields), it is still not the modelstore database that is involved: those IDs are stored in the business/transaction database, in the SQLDictionary table.
And if a table or view is defined in the AOT but does not exist in the business/transaction database, then during the synchronization process AX informs SQL Server to create it.
Is that right so far?? Does synchronize do anything else?
First of all, notice that your description is all about synchronization, while my quote is about compilation. These are two separate things.
What synchronization does is that it reads information about objects defined in AX application metadata (in AOD/modelstore) and ensures that these objects exist in the (transaction) database. For example, if you install a model with a new table, synchronization reads information about the table (name, ID, fields, indexes etc.) and call the usual CREATE TABLE command in SQL database. Similarly with updates/deletes. SqlDictionary table just helps AX to keep track of what is in DB / should be changed.