Relational model data export required (for each refresh)

Posts   
 
    
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 20-Nov-2013 10:36:06   

Haven't been able to find an answer to this question in the forums.

We're using the command line tools in our effort to completely automate any change in our database into our source control system.

Problem is that after each refresh of the relational model LLBLGen states that "Relational model data export required".

We work with database first and use our own change scripts so we actually don't need the LLBLGen built-in DDL SQL Update scripts.

Is there a workaround to this issue?

The command line output is:

LLBLGen Pro Command line project refresher v4.1.0.0.11142013
(c)2002-2013 Solutions Design. http://www.llblgen.com
Refreshes LLBLGen Pro relational model data on the command line.
Initializing...
Initialization complete.
Loading project 'MyProject.llblgenproj'
Project 'MyProject' loaded successfully from file 'MyProject.llblgenproj'.
Validating project...
Project validation successful.

=====================
Exception caught.
=====================
Message: Project 'MyProject' requires DDL SQL update script export prior to relational model data refresh. Please load
 the project into the designer and perform this action from the designer.
Source: CliRefresher
Stack trace:
   at SD.LLBLGen.Pro.Tools.CommandLineRefresher.Startup.StartProcess(String projectFile, String userId, String password,
 Boolean overwriteCredentials, DatabaseType dbType, Boolean showErrorLog)
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 20-Nov-2013 11:25:50   

Please perform for testing the refresh in the designer and export the DDL SQL script to see what is in there: the script will signal what has changed in the relational model data that justified an export. Then check back whether that makes sense or that it might be a bug in our code.

I think though that the requirement to export the DDL SQL comes BEFORE the refresh not after it, as it performs a full validation & relational model data adjustment based on the project data and it then concludes something in the relational model data has changed so you have to export that first and run on the database BEFORE you refresh. So you likely made a change in the project which has an effect on the relational model data.

Frans Bouma | Lead developer LLBLGen Pro
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 20-Nov-2013 13:20:09   

Please perform for testing the refresh in the designer and export the DDL SQL script to see what is in there: the script will signal what has changed in the relational model data that justified an export.

Below is the content of the DDLSQL file. It's the same content each time a ddl refresh is required:


-- ----------------------------------------------------------------------------------------------------------------
-- Generated by LLBLGen Pro v4.1  Build: November 14th, 2013
-- SQL Server 2000/2005/2008/2008R2/2012/Express DDL Script generated from project: MyProject
-- Project filename: C:\src\MyProject\MyProject.llblgenproj
-- Script generated on: 20-nov-2013 12:40.40
--
-- This is an Update script for updating an existing data model to a newer version. If you want DDL SQL for a new model,
-- please create a Create script instead. 
--
-- This script might create schemas, which requires you to assign a proper user to the schema. Adjust the CREATE SCHEMA
-- statements below, if any, to avoid errors at runtime.
--
-- Please run the scripts in the right order, use the timestamp in the filename and inside this script for that.
-- This script might need adjustment in some statements. You should consider this script as a starting point for
-- upgrading the existing data model.
-- ----------------------------------------------------------------------------------------------------------------
-- ###############################################################################################################
-- Drop constraints referring to elements which are changed in this script (constraints are recreated later on)
-- ###############################################################################################################

USE [core]
GO

ALTER TABLE [dbo].[ExternalFolderVisibility] DROP CONSTRAINT [FK_ExternalFolderVisibility_Folders]
GO

-- ###############################################################################################################
-- Rename statements
-- ###############################################################################################################

USE [core]
GO

-- ###############################################################################################################
-- DROP statements for elements no longer needed or replaced elements.
-- ###############################################################################################################

USE [core]
GO

-- ###############################################################################################################
-- ADD statements for new elements (except FK/UC)
-- ###############################################################################################################

USE [core]
GO

-- ###############################################################################################################
-- ALTER statements for table fields and ADD statements for new primary key constraints
-- ###############################################################################################################

USE [core]
GO

-- ###############################################################################################################
-- ADD statements for new foreign key constraints and unique constraints
-- ###############################################################################################################

USE [core]
GO

ALTER TABLE [dbo].[ExternalFolderVisibility] 
    ADD CONSTRAINT [FK_ExternalFolderVisibility_Folders] FOREIGN KEY
    (
        [FolderId] 
    )
    REFERENCES [dbo].[Folders]
    (
        [FolderId] 
    )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION
GO



In the project file the following line is changed:

<NormalRelationship Name="ExternalFolderVisibility.Folder-Folder.ExternalFolderVisibilities" Start=":ExternalFolderVisibility" End=":Folder" StartNavigator="Folder" EndNavigator="ExternalFolderVisibilities" Type="4" DeleteRuleAction="1">

The change is DeleteRuleAction="1" being added to the element.

We are several devs using the same project file using GIT, and I can't say whether this is a bug in your code or our usage of it :-)

I think though that the requirement to export the DDL SQL comes BEFORE the refresh not after it, as it performs a full validation & relational model data adjustment based on the project data and it then concludes something in the relational model data has changed so you have to export that first and run on the database BEFORE you refresh.

You're right of course, it didn't re-appear when refreshing multiple times after each other. We just can't figure out why the "ExternalFolderVisibility" table re-occurs in the DDLSQL update scripts, when we (AFAIK) didn't make changes in the project.

Perhaps you can point me in the direction of what could trigger this?

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 20-Nov-2013 21:58:07   

The update script is needed to synch the database schema with your model.

Did you execute this ALTER TABLE command against your schema?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 21-Nov-2013 11:46:02   

For the relationship given which now has noaction for delete cascade, was it changed to that by any of your developers?

Frans Bouma | Lead developer LLBLGen Pro
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 22-Nov-2013 11:13:17   

AFAIK we haven't made changes to that table in a long time (3+ months).

I'll try including the DDL SQL Update script as standard part of our own creation/change scripts and ask the team to keep an eye out on this issue when making db changes.

Regardless, I'll follow up again next Friday, if we don't see the issue re-appearing.

Thanks for your support so far.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 22-Nov-2013 11:48:03   

It could be due to a bug we had in the relationship rule code, where defaults were always propagated to the relational model data. It might be that caused the change in the llblgen project which then ended up in the main project file in the git repo. Anyway, we fixed this issue some time ago so it shouldn't happen again.

Frans Bouma | Lead developer LLBLGen Pro
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 29-Nov-2013 15:40:18   

Our commandline dal generation has been running without exceptions for a week now, so it seems to be resolved.

Thanks for the help!

kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 10-Dec-2013 13:34:23   

And now it's recurring. This time with steps to reproduce:

  1. Run this SQL:
ALTER TABLE [dbo].[webpages_UsersInRoles] ADD CONSTRAINT [UK_webpages_UsersInRoles_UserId] UNIQUE NONCLUSTERED ([UserId])
  1. Run CliRefresher.exe and CliGenerator.exe

Runs fine...

  1. Run CliRefresher.exe and CliGenerator.exe again

Now I get this:

=====================
Exception caught.
=====================
Message: Project 'MyProject' requires DDL SQL update script export prior to relational model data refresh. Please load
 the project into the designer and perform this action from the designer.
Source: CliRefresher
Stack trace:
   at SD.LLBLGen.Pro.Tools.CommandLineRefresher.Startup.StartProcess(String projectFile, String userId, String password,
 Boolean overwriteCredentials, DatabaseType dbType, Boolean showErrorLog)

The script that is suggested to run is this:

ALTER TABLE [dbo].[webpages_UsersInRoles] DROP CONSTRAINT [UK_webpages_UsersInRoles_UserId]
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 10-Dec-2013 13:40:35   

It could be related to a git merge conflict in the project file that happened just before.

However, I find it stange that the first refresh runs fine - but the next requires a sql update (that reverts the initial change).

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 11-Dec-2013 03:27:12   

Could you please try reproducing this in a new project using the latest release of LLBLGen Pro? Then send us the repro project, please.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39888
Joined: 17-Aug-2003
# Posted on: 11-Dec-2013 11:08:07   

please also check the preferences set in the designer for the user which also runs the clirefresher on that machine, as those preferences are used (project settings are overriding these, if set, most of them are 'default' by default which means they use the preferences setting). Here one can define whether 'Unique constraints follow dbunique constraints' is set to true/false, which is a project setting as well (though its default value is 'default' so it will pick the preferences setting). It looks like the UC in the db isn't added as a uc to the model, and therefore it's removed again after the validation.

It's also good to do this in the designer so you get a log what happened exactly so you can see what's done (and what's NOT done)

Frans Bouma | Lead developer LLBLGen Pro
kbjorn
User
Posts: 13
Joined: 10-May-2005
# Posted on: 11-Dec-2013 14:39:51   

Seems we were using same settings and changing the

Unique constraints follow dbunique constraints

doesn't change behavior.

When refreshing with the designer I didn't get the UC reflected in the generated code either.

However I made a workaround that solved it (I got the UC in the code and no exceptions when refreshing):

  1. Removed the table from the designer.
  2. Set the project settings to automatically add new elements.
  3. Closed the project saving the changes.

Running the refresher/generator script again now gives no exceptions - also after running it several times.

This is sufficient for me now, so I'll not investigate deeper.

Just as a note: The table in question consists only of a combined PK (UserId, RoleId). I don't know if making the UserId a UC as well caused confusion...

Thanks again for the help.