Database.SaveToFolder doesn't include 'Data' folder?

I am doing the following, for experimentation purposes:
var targetDb = new Database();
targetDb.RegisterForDataCompare(options.DbDirectory.FullName,null,Options.Default);
var dbInfo = targetDb.DbInfo;
var outPath = Path.Combine(options.OutFilepath, 'tempDb');
if (!Directory.Exists(outPath))
{
	Directory.CreateDirectory(outPath);
}
targetDb.SaveToFolder(outPath, dbInfo);

Which is:
- registering a database from a source-controlled folder of files, which includes source controlled static-data
- saving that database out to a new folder of files

I've noticed that none of the static-data is written out to the new tempDb folder, what am I missing?

The wrangling involving dbInfo was an attempt to fix this, thinking that re-using the existing db info loaded in step 1 would solve the problem but it didn't. The 'RedGateDatabaseInfo.xml' written out into tempDb has 'DataFileSet' and 'DataFile' entries I'd expect to see, but the 'Data' folder itself isn't in the directory structure.

When then doing a comparison between two dbs, one registered from the original source folder and the other registered from the tempDb folder, the data migration script thinks that all static data is missing so creates a script that attempts to insert all rows.


Tagged:

Comments

  • mjashtonmjashton Posts: 10 New member
    Can no-one from RedGate confirm that static data is supposed to be written out as part of the database.SaveToFolder() operation?
  • Hi - sorry for the delay on this.

    To clarify, the Database class only stores schema information and Database.SaveToFolder() will only write out schema to a folder. The RegisterForDataCompare method creates a Database instance with limited schema information specifically relevant to Data Compare (ie mostly focusing on tables and views rather than other object types) which can then be fed into ComparisonSession and other related classes to do the actual data operations.
  • mjashtonmjashton Posts: 10 New member
    Ok, thanks for the info. The background to this question (and the other one you answered around idempotent data scripts) is that I have been trying to work around a problem involving getting automation working when one half of the comparison is a snapshot rather than a backup. Because a snapshot doesn't have any data this throws an exception using SQL Compare command line, but I'd hoped to be able to generate a synchronisation script that included the static data under source control. Using the SDK I could do a data comparison between a DB from snapshot and the source controlled folder, and I'd hoped to be able to use this comparison to create a drop-and-create approach to static data. I guess I need to move on to plan C, now that plan A and B have been ruled out.
    Thanks again.
Sign In or Register to comment.