views:

25

answers:

1

Hi,

I'm trying to use the database project in VS2010, but my setup is a bit different from standard and I can't find an easy way to get it to work.

I have a "model" project which contains some xml model definitions of a simple information for an ETL process. As well as the schema for the supplied information, it contains other metadata, for example details of which columns need to be matched up with other tables, what to do in case of a non-match, etc, etc.

Using T4 templates, I then generate sql scripts, views and tables to manage the whole thing - one sql file per xml file. There are around 30 xml definitions, but the number of parameters is small and the pattern very repetitive, so it works well.

I want to dump these sql files into the database project, in order to get it to generate the deploy scripts and identify database changes for me. I can arrange for the files to be combined into one script. Is there a way to get VS to analyse the scripts automatically, or do I need to import them every time?

EDIT: I originally asked about getting VS not to split my scripts up into individual components. I found a solution to this: copy the existing script into the project, and - crucially - change the "build action" for the script to "build" (for some reason, default is "not in build"). VS will then add the item into the model and it will be part of the generated scripts - yay! However, still no way to reference scripts in other projects...

I've read the MS how-to for database projects, but didn't find anything in it that seemed relevant

Thanks for your help,

+1  A: 

You can do this with T4 Toolbox. Here is how: http://www.olegsych.com/2010/03/t4-tutorial-integrating-generated-files-in-visual-studio-projects/. Specifically, you want to take advantage of the Template.Output.File and Template.Output.Project properties.

Oleg

Oleg Sych
Thanks - I was trying to avoid adding a dependency on T4Toolbox to the project, but I think there is no other way (other than writing a ton of my own code in T4!)So now I have it working nicely.Only one thing: to get my scripts into the output of building a database project, the script needs to have a "Build Action" of "Build". But when I set the property using T4Toolbox as per docs, I get an error "Build Action Build is not supported for x.sql"Do you know the correct setting? I could not find any useful indication in the .dbproj file?
mr_miles