DotNet Support Blog
Showing posts with label VisualStudio. Show all posts
Showing posts with label VisualStudio. Show all posts

Do you use database projects in Visual Studio? If not, then now is a good time to start. It is the best way I have found to source control my databases without actually sticking the database file itself in the repository. It is very simple to add to your solution and creates a default directory structure for your create scripts, change scripts and queries. Best of all the project will be recognized by source control and added to the source code repository. This means you can keep versioned scripts for maintainability. It also gives you the option to do the dreaded rollback!

Lets start by creating a database project of our own. To start, we will create a blank Visual Studio solution.

screenshot-2008-05-05_18_56_00

Now click File -> Add -> New Project.

screenshot-2008-05-05_18_57_08

You should get the dialog below. Now we will look in the node of "Other Project Types", click "Database" then select "Database Project". This will give us the opportunity to name our database project. We will call this one by the database we are going to be using, good ol' Northwind.

screenshot-2008-05-05_18_58_44

Next you will be asked to setup a database reference. So here all we have to do is add a new reference to the Northwind database.

screenshot-2008-05-05_18_59_29

My database will be in SQL Server, yours can be in any of the choices shown below.

screenshot-2008-05-05_19_01_31

Now we just set the server name and choose the Northwind database.

screenshot-2008-05-05_19_02_07

You should then test your connection (out of good practice) and see the dialog below upon success.

screenshot-2008-05-05_19_02_15

Now we will see our database reference shown in the original list of references. Just double click on your newly added reference.

screenshot-2008-05-05_19_02_31

Now your project should look something like the shot below.

screenshot-2008-05-05_19_02_51

Once we get this far, we need to start filling our folders with database scripts. You can add new folders if you wish, but I think the default folder structure is good enough. Now then, we can use the database publishing wizard to get our first create script into the "Create Scripts" folder.

Double click the reference to your database in the database references and it should bounce you to the server explorer window with your data connection all setup.

screenshot-2008-05-05_19_05_20

Right click your data connection and click "Publish to provider..." to start the database publishing wizard.

screenshot-2008-05-05_19_05_31

Now we select the database we would like to publish, so again I will choose Northwind.

screenshot-2008-05-05_19_05_52

Now with the "Script to file" option chosen, we will browse to the "Create Scripts" folder in our database project to put the outputted .sql file.

screenshot-2008-05-05_19_06_51

Now we get to choose some options. I am going to set the output for SQL Server 2005 and select to script the database schema only.

screenshot-2008-05-05_19_07_18

Now we can review the summary of what we have configured and click finish.

screenshot-2008-05-05_19_07_26

Upon clicking finish, we will see the progress of the .sql file being scripted to the hard drive.

screenshot-2008-05-05_19_08_07

Ok, for some reason I couldn't find a refresh button in the database project to see the file that was created so we will right click the "Create Scripts" folder and click "Add Existing Item..."

screenshot-2008-05-05_19_10_15

Then browse to our .sql file and click the "Add" button.

screenshot-2008-05-05_19_10_27

Now we should see it in our project and we can also see the contents of the generated script by opening it in the editor.

screenshot-2008-05-05_19_12_20

screenshot-2008-05-05_19_12_31

It really is just that simple. I mean if nothing else you have a designated place to put all your SQL scripts for your database. The big plus is that your scripts will be source controlled. Also, anyone who opens the solution will know exactly which databases are used by the project.

 

Microsoft has just released a hotfix for a number of issues that have been plaguing me for some time in Visual Studio 2008. The issues involved have to do with the visual designer and the HTML code editor and a number of different input focus and slow input situations.

You can get the hotfix from here:

Blog Hotfix

You can read the official fix list at the link above, but here are a few issues that it has addressed for me specifically:

Visual Designer Focus issues

In the the Visual Web Forms designer I would often be unable to select controls inside of container controls or DOM elements. Instead of selecting a contained control the control's container would select and only repeated clicking and selecting de-selecting would eventually get the control focused. The fix now gets selection right in most cases. Also multiple selection is no longer so sketchy. I also had a number of issues with cutting and pasting of controls almost consistently crashing VS - which also seems to be gone now.

Visual Designer and Property Sheet Synching

I had major problems with the property sheet not synching with the selected control. In many situations the sync would simply not work at all or require repeated clicks on the Properties context menu. Now controls select much more quickly and the property sheet synchs properly although there's still a second or so delay, which is annoying but acceptable.

Slow Master Page Loading

I had major issues with master pages loading taking forever when the page loaded for the first time. It would often take 20-30 seconds for the first form to come up. Subsequent forms were much faster, but the first load was horrendous. Now in the same project I was blown away to see that the load was maybe 5-10 seconds with subsequent pages loading nearly instantly.

Performance for loading into the Visual Editor in general is much improved.

Keyboard Input lagging in the HTML Source Editor

On occasion I would have situations where the editor would be up and running and there'd be a cursor, but I'd type into the editor and nothing would happen. I'd have to click off and back into the editor to properly get focus and then it would work. In some cases the keyboard buffer was even locked where any additional keys would bring a white overlay on the editor. Now with the hotfix that problem seems to have disappeared. Also the editor seems a lot more snappy in general.

Mysterious View Code Availability

The patch also fixes the View Code context menu option which prior to the patch was extremely hit or miss. Sometimes the menu option would show up - other times it wouldn't. Apparently a lot of the problems fixed by this patch have to do with idle state detection and some hardware configuration apparently never entered the necessary wait states to update certain VS UI features. Other things that can be affected by this are things like Syntax highlighting taking a while to show up or the member list to populate. All of that too is now working as it should.

What's odd is that I *really* didn't notice these problems as acutely until a few weeks ago around the same time Microsoft had put out a pre-release patch. I tried the patch about a week ago and all the above issues disappeared. Some of these fixed issues appear to be side effects of this patch since they're not explicitly mentioned on the fix list, but hey I'm not arguing. This patch has brought some sanity back into my development environment.

The patch has a few additional fixes that you can find on the download page. The fixes will eventually end up in Visual Studio 2008 SP1, but I suspect most people will want to install this hotfix since these issues affect a wide range of the product.

 

Recently I found out this great add-on for Visual Studio 2008 called PowerCommands. PowerCommands Extends the functionality of Visual Studio 2008 by adding some features which we all want built into Visual Studio. PowerCommands provides the following:

1. My favorite: Copy Reference, very useful indeed, and you all know it, just right click on the reference you want copied and select copy reference, now go to the another project and just paste that reference

* you can copy all the references by right clicking on references.

2. Another useful option is Collapse Projects, click on the solution and collapse all the projects at ounce. Very handy if you have a project loaded solution.


3. Email Code Snippet, I don’t know about how useful is it, but its cool :).