Invoking the data generator from the command line<p><font face="Verdana, Geneva, Arial, Sans-serif" size=2>Do we have the ability to invoke the data generator from the command line or as a part of the deployment of the database (i.e. using the <strong>Deploy Selection </strong>command)?</font></p> <p><font face=Verdana size=2>This would be useful in automated build setups where we need to perform some sort of intermediate check after a successful creation of the database on the server but before actually loading some (test) data in it.</font></p> <p><font face=Verdana size=2>-Tanveer Rashid</font></p>© 2009 Microsoft Corporation. All rights reserved.Tue, 02 Dec 2008 12:49:37 Z5e750da2-24a0-4e4e-8eae-761f56c27b2chttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#5e750da2-24a0-4e4e-8eae-761f56c27b2chttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#5e750da2-24a0-4e4e-8eae-761f56c27b2cTanveer Rashidhttp://social.msdn.microsoft.com/Profile/en-US/?user=Tanveer%20RashidInvoking the data generator from the command line<p><font face="Verdana, Geneva, Arial, Sans-serif" size=2>Do we have the ability to invoke the data generator from the command line or as a part of the deployment of the database (i.e. using the <strong>Deploy Selection </strong>command)?</font></p> <p><font face=Verdana size=2>This would be useful in automated build setups where we need to perform some sort of intermediate check after a successful creation of the database on the server but before actually loading some (test) data in it.</font></p> <p><font face=Verdana size=2>-Tanveer Rashid</font></p>Fri, 16 Jun 2006 04:56:46 Z2006-06-19T16:30:07Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#111dd67d-238c-4e64-8e08-6157875e6f2ahttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#111dd67d-238c-4e64-8e08-6157875e6f2aMickey Ghttp://social.msdn.microsoft.com/Profile/en-US/?user=Mickey%20GInvoking the data generator from the command lineI am pretty sure I heard them say that you will be able to use the data generator from the command line, but I am not sure if it is in the current CTP or not.Fri, 16 Jun 2006 12:29:08 Z2006-06-16T12:29:08Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#ad205659-c738-4d07-80ff-93464f9c19f4http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#ad205659-c738-4d07-80ff-93464f9c19f4Jon Liperi - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jon%20Liperi%20-%20MSFTInvoking the data generator from the command line<p>In CTP3, we do not provide a tool/executable to invoke a data generation plan from the command line. However, we do provide a public API for invoking a .dgen so you can write a simple executable yourself. The call you need to make is:</p><font color="#0000ff" size=2> <p></font><font color="#008080" size=2>DBTest</font><font size=2>.GenerateData(<br>      <font color="#000000"><em>string dataGeneratorFilePath</em></font></font><font size=2>,<br>      <em>string connectionString</em>);</font></p> <p><font size=2>The DBTest class is located in namespace Microsoft.VisualStudio.TeamSystem.Data.UnitTesting.</font></p> <p><font size=2>Thanks!</p></font>Fri, 16 Jun 2006 13:10:25 Z2006-06-16T13:10:25Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#78017142-a3c2-4bcd-9e73-889ba7ae280dhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#78017142-a3c2-4bcd-9e73-889ba7ae280dJamie Laflen MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Jamie%20Laflen%20MSFTInvoking the data generator from the command line<p> </p> <p>DataGenerator is also exposed as a MSBuild task.  This makes it very easy to incorporate DataGeneration into any build process.  A simple project file using the MSBuild task is:</p> <p>&lt;Project DefaultTargets=&quot;DataGen&quot; xmlns=&quot;<a title="http://schemas.microsoft.com/developer/msbuild/2003" href="http://schemas.microsoft.com/developer/msbuild/2003">http://schemas.microsoft.com/developer/msbuild/2003</a>&quot;&gt;<br>  &lt;!--Import the settings--&gt;<br>  &lt;Import Project=&quot;$(MSBuildBinPath)\Microsoft.VisualStudio.TeamSystem.Data.targets&quot; /&gt;<br>  <br>  &lt;Target Name=&quot;DataGen&quot;&gt;<br> &lt;DataGeneratorTask<br>  ConnectionString=&quot;$(ConnectionString)&quot;<br>  SourceFile=&quot;$(SourceFile)&quot;<br>  PurgeTablesBeforePopulate=&quot;$(PurgeTablesBeforePopulate)&quot;<br>  /&gt;<br>  &lt;/Target&gt;<br>&lt;/Project&gt;</p> <p>There are other options on the build task and I would expect this to be flushed out more in future releases.</p>Fri, 16 Jun 2006 19:48:52 Z2006-06-19T16:30:07Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#5f226ffc-2ecb-452f-bd7c-928c537fbbe0http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#5f226ffc-2ecb-452f-bd7c-928c537fbbe0ccotehttp://social.msdn.microsoft.com/Profile/en-US/?user=ccoteInvoking the data generator from the command line HI,  I tried your solution and I get the following error<br> <p>&quot;C:\SQLDATA\test.txt&quot; (default target) (1) -&gt;<br>(DataGen target) -&gt;<br>  C:\SQLDATA\test.txt(5,6): error MSB4018: The &quot;DataGeneratorTask&quot; task failed<br>unexpectedly.\r<br>C:\SQLDATA\test.txt(5,6): error MSB4018: System.NullReferenceException: Object<br>reference not set to an instance of an object.\r<br>C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.VisualStudio.TeamSyste<br>m.Data.DataGenerator.ConfigurationLoader.LoadConfiguration()\r<br>C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.VisualStudio.TeamSyste<br>m.Data.Tasks.DataGeneratorTask.Execute()\r<br>C:\SQLDATA\test.txt(5,6): error MSB4018:    at Microsoft.Build.BuildEngine.Task<br>Engine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, Task<br>ExecutionMode howToExecuteTask, ITask task, Boolean&amp; taskResult)</p> <p>    0 Warning(s)</p>The command line I use is:<br>MSBUILD text.txt<br><br>Here is my test.txt file content:<br><br>Project DefaultTargets=&quot;DataGen&quot; xmlns=&quot;<a href="http://schemas.microsoft.com/developer/msbuild/2003">http://schemas.microsoft.com/developer/msbuild/2003</a>&quot;&gt;<br>  &lt;!--Import the settings--&gt;<br>  &lt;Import Project=&quot;C:\Program Files\MSBuild\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.VisualStudio.TeamSystem.Data.Tasks.targets&quot; /&gt;<br>  &lt;Target Name=&quot;DataGen&quot;&gt;<br>     &lt;DataGeneratorTask<br>          ConnectionString=&quot;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DBAdventureWorks;Data Source=CC-Acer\ACER_DEV2008&quot;<br>          SourceFile=&quot;dgpManagerEmployees.dgen&quot;<br>          PurgeTablesBeforePopulate=&quot;True&quot;<br>      /&gt;<br>  &lt;/Target&gt;<br>&lt;/Project&gt;<br><br>Can it be related to the fact that I am using RC0 version of DBpro?<br><br>Thanks!<br>CcoteMon, 01 Dec 2008 10:11:25 Z2008-12-01T10:11:25Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#01850218-7f2f-46f3-9be0-46bf595ef346http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#01850218-7f2f-46f3-9be0-46bf595ef346Genevieve Orchardhttp://social.msdn.microsoft.com/Profile/en-US/?user=Genevieve%20OrchardInvoking the data generator from the command line It looks like you need to update the .targets file in your test.txt file. Try using this instead:<br><br>    &lt;Import Project=&quot;$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\TeamData\Microsoft.Data.Schema.SqlTasks.targets&quot; /&gt;<br><br>Let us know if you still encounter problems.<hr class="sig">-Genevieve Orchard (VSTS Database Edition Test Team)Mon, 01 Dec 2008 20:51:57 Z2008-12-01T20:51:57Zhttp://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#0a43f09c-5316-4176-9bb6-ce61eb1f9007http://social.msdn.microsoft.com/Forums/en-US/vstsdb/thread/5e750da2-24a0-4e4e-8eae-761f56c27b2c#0a43f09c-5316-4176-9bb6-ce61eb1f9007ccotehttp://social.msdn.microsoft.com/Profile/en-US/?user=ccoteInvoking the data generator from the command line It works perfectly.<br><br>Thank you!Tue, 02 Dec 2008 12:49:22 Z2008-12-02T12:49:22Z