Scott on Writing

Musings on technical writing...

Database Projects in Visual Studio .NET

Until about two years ago, I was completely ignorant about Visual Studio .NET's Database projects.  That is, until my wife let me in on the secret.  Actually it was kind of funny, she came home from work one day excited after she had learned about the Database project type in VS.NET and wanted to show me how to create/setup/use such a project.  We were about to head out of the house, so I said, Later, and over the next few weeks she mentioned it occassionally, but there never was a good time.

Finally, we both had some free time and I asked her to show me the Database project.  Since then I've been using them in every single data-driven ASP.NET Web application project I've created, and have immensely enjoyed the benefits.  Many thanks, my dear.

I recently wrote an article on 4Guys about the advantages of Database projects and how to get started using them.  I invite you to read this new article, Database Projects in Visual Studio .NET.  Additionally, be sure to check out the Visual Studio .NET Database Projects sample chapter from Database Access with Visual Basic .NET.

To summarize the advantages of Database projects, I quote from my article on 4Guys:

  • Source control on database objects - if you are using source control (and you most definitely should be), the scripts managed through the Database project can be added to your source control provider. This means that any changes to your database objects will be recorded by your source control provider, thereby providing the myriad of advantages that source control affords (rolling back to older versions, a complete history of changes, etc.).
  • A centralized development experience - rather than having to poke through SQL Enterprise Manager you can manage your database-related objects through the same IDE that you are using to manage the pages and components in your ASP.NET application.
  • An improved text-editor - Visual Studio .NET's text-editor is head and shoulder's above SQL Enterprise Manager's built-in text-editing experience. Additionally, with SQL Enterprise Manager many of the dialog boxes that are used to create/edit database objects are modal, thereby making it impossible to examine other facets of the database when creating/editing a database object. Not so when doing it through Visual Studio .NET.
  • Ease of deployment - if you need to quickly replicate your database's structure having a Database project makes it as easy as right-clicking on the Database project's objects and selecting the 'Run' context-menu option.

posted on Wednesday, July 13, 2005 12:07 AM

Feedback

# re: Database Projects in Visual Studio .NET 7/13/2005 1:34 AM Michael Teper

Hmm, I've actually found them quite useless. Maybe I just don't get it, but what has always mattered to me was not the table create script but rather the table *change* script. Yes, I can store change scripts in the db project (and I do), but its hardly any more special than any other SCC enabled folder.

# re: Database Projects in Visual Studio .NET 7/13/2005 3:40 AM Barry Kelly

What you fail to mention is that the simple interactive SQL query execution interface loves to rewrite everything you type, and that somebody in Microsoft is still under the misguided impression that people prefer to use GUI tools rather than type SQL manually.

# re: Database Projects in Visual Studio .NET 7/13/2005 9:01 AM Rajeev Gopal

Well, I have used SQL Server very little compared to Oracle and do not know how VS.NET Database project supports that. The support for VSS integration for the Database objects is a news to me. May be I will give it a try. As of now, I am using Bethnic Software's Golden and PLEdit to access Oracle db.

# re: Database Projects in Visual Studio .NET 7/13/2005 12:55 PM Roger Helliwell

I agree with Barry. When using the GUI tools, VS creates mangled, unindented code that is nearly impossible to decipher. But as Scott pointed out, the VS text-editor is way easier to use than Enterprise Manager. I can't hardly wait till there's intellisense!

# re: Database Projects in Visual Studio .NET 7/13/2005 1:41 PM Cheng Yuan Yap Ye

I use the database project religiously in all my projects. I've added a few tips about this in my blog.

# re: Database Projects in Visual Studio .NET 7/13/2005 4:40 PM Brian

This may be off topic but is anyone trying to use the Firebird database? I read several articles and got all excited about moving from MySQL to Firebird but did not find it very user friendly for GUI tools or database features. Is it just a perk to have an auto increment field? Because that is the major issue that keeps me from trying it. The solution is to use another query to generate an id, store in in a local variable, then include it with the insert of new data.

I would like to use MySQL but on windows it has issues with performance, at least for me. And SQL Express will not have full text support, and finally I can't spend the $20,000 for a processor license for SQL Server. I will stick with MySQL for now.

# re: Database Projects in Visual Studio .NET 7/14/2005 12:02 PM Haacked

Great article. I think there's room for part 3 where you can cover Command Files and how VS.NET can script not only schemas, but data.
http://www.awprofessional.com/articles/article.asp?p=31764&seqNum=7

One issue that isn't much addressed is how to use database projects in a real world deployment scenario.

For example, you are working on an existing database project. You modify 12 scripts and apply them to your dev db. Now your deployment manager is ready to deploy those scripts to staging. How do you separate them? Do you make your deployment manager use Source Control to get all scripts that have changed since last deployment? Do you group those in a particular command file and after its executed, move it to an archive folder?

Thoughts?

# re: Database Projects in Visual Studio .NET 7/14/2005 7:04 PM Cheng Yuan Yap Ye

Wow, thanks for the link, Haacked! I think the link to the article you provided answered all your questions — Change Scripts.

# re: Database Projects in Visual Studio .NET 7/17/2005 12:13 PM Ben Strackany

trackback

# re: Database Projects in Visual Studio .NET 7/28/2005 5:01 AM Simon Green

I have been very intrested in trying your "Database Projects in Visual Studio .NET" since i read your artical a few weeks back Scott. So yesterday i got stuck into trying it in my latest project. Evey thing seemed to go fine added in all the itmes got everything in VSS. I ran the scripts agist various database connections i have set up. The only problem i am having is when i go to edit the sql of an existing query and try to use the VS query builder it just comes up blank with none of the table info that the SP currently has. Another thing is that it wont let me put in Parameters in the queries when i go to create a new SP. AM i missing somehting or is anybody else having these problems

# re: Database Projects in Visual Studio .NET 8/3/2005 4:45 PM Darren Kopp

Similarly i have not used them unto just recently. I don't really use it that much except to just quickly build the query then i'll jump to code and then tweak it.

# re: Database Projects in Visual Studio .NET 8/18/2005 7:41 PM Tod Birdsall

Thanks for the helpful article. I put together a list of resources that I found helpful while learning to use Visual Studio 2005 DataBase Projects (including Scott's article). I also discuss how VS 2005 no longer generates Command Files execute a batch of sql scripts. You can find it here:
http://tod1d.blogspot.com/2005/08/visual-studio-database-projects-and.html

# Code Snippets in Visual Studio 2005 12/27/2005 4:05 PM Scott on Writing

# re: Database Projects in Visual Studio .NET 11/23/2006 7:40 PM 数据恢复

okery!

# re: Database Projects in Visual Studio .NET 11/25/2008 7:31 PM Tadeu Braganza

Thanks for the article. I would like to know if its possible to display the output of the executed SQL script file in a grid format ( same as in Management Studio) rather then displaying in default text format.

# re: Database Projects in Visual Studio .NET 12/17/2008 6:14 PM Chris

This article talking about how to create full text index on database project. Hope it helps.
http://www.fulltimedba.com/2008/12/18/HowToEnableAndCreateFullTextSearchFromVisualStudioDatabaseProject.aspx

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55618.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3020100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1193.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3020100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.00160
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403020

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.67322
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403020

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles