During an import of the modelstore on a model database that contains entries on the new table while building CU7, I receive the fiollowing error:
VERBOSE: The AXUtil command was started in the mode: IMPORTSTORE. VERBOSE: VERBOSE: Working against model store PBZAXSQL01/AX6_DEV_Build_model. VERBOSE: VERBOSE: ERROR: The DELETE statement conflicted with the REFERENCE constraint "FK_ManifestHistoryHasCategoryId". The conflict occurred in database "AX6_DEV_Build_model", table "dbo.ModelOperationHistory", column 'CategoryId'.
I've noticed that this table was introduced in CU7, and that it contains information about model operations.
Deleting the records from the table before performing the modelstore import seems to resolve the problem. However, I don't know how this table is used by the system.
Has anyone had a similar issue ?
We are facing the same issue when trying to import model store
Is there a way out to solve this issue?
Please try to reinitialize the modelstore schema. You can read about on my blog here:
I had already initialized the modelstore schema during the CU7 upgrade. I received the error later on, during the execution of an automated AX build in the modelstore import step.
The workaround I used to be able to go forward was to execute a straight SQL "delete from ModelOperationHistory", and then teh import worked.
However, I still don't know how the table is used by the AX framework, and what the logic behind this table is. It would be interesting to know so that I can apply the proper procedure rather than my "workaround".
You're right. That is an interesting constraint. You are being blocked from deleting in [ModelOperationHistory] until the referenced categories are first (or cascade) deleted from [ModelManifestCategory].
Could you please elaborate some more on what steps you have done? You say you are importing a new modelstore to a model database (1st step), then trying to build it using AXBuild (2nd step). Is the AOS running while you import the modelstore?
Starting from a CU7 upgraded system, these are the steps being executed:
1) Get the latest sources from VCS and combine them into a single XPO
2) Import the Standard CU7 upgraded modelstore into the build system.
3) Create the new target model on the build system using the model manifest file.
4) Import the label files into the target model.
5) Import the combined XPO into the target model
6) Import Visual Studio projects into the target model
7) Export the target model for later use
8) Import the deployed modelstore of the "previous build" into the build system to get rid of ID conflicts. This modelstore is CU7 upgraded and AX schema reinitialized.
9) and so on with the next step...
The problem occurred during the execution of step 8.
Just one more quick question; the AXUtil being used to import the modelstore is the one for CU7, right?
Can you figure out what models have been added/removed by comparing the new modelstore with the old one? I'm just wondering if there is a stored procedure deleting a modelmanifest causing it ty try delete the underlying chained rows.
You can compare the modelstores by using PowerShell:
The AXUtil used is CU7 upgraded, like all components on this installation.
There is only one (custom) model added during the build process, and at step 8, the ModelOperationHistory table only contained records for this model, with different model ID and Model Manifest ID compared to the the previous build's modelstore. This is normal, because in step 3 we create a new empty model.
I have run into this issue exporting/importing modelstore from QC to production. We had to run the following command.
axutil schema /s:servername /db:database_name_model
I could reproduce this issue. In my case I tried to install a exported modelstore with finished CU7 upgrade procedure steps into an empty modelstore (installed database, deleted all models, initialize modelstore).
deleting the ModelOperationHistory also solves my issue.
Thanks to Stefano for this.
Not sure I understand what you mean.
You had an standard AX 2012 R2 with CU7 modelstore.
You then tried to install this into an "empty" modelstore? You installed a new AX database with SYS+SYP models, deleted them, then initialized modelstore (schema), and then tried to import the previously exported modelstore?
I have got the same error while importing modelstore into a fresh database.
Workaround by deleting records from ModelOperationHistory helped.
Please test before releasing.
I just ran into this issue myself and used another workaround:
1. Create a temporary schema in the model store database.
2. Import the model store file into the temporary schema.
3. Apply the temporary schema.
It seems that this is a safer option since it only uses supported features of the model store utilities.
I had the same issue.
Removing the data from ModelOperationHistory worked.
Many thanks, Daniel Weichsel, for your workaround!