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!

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

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles