This post originated from an RSS feed registered with .NET Buzz
by Raymond Lewallen.
Original Post: A nice thing about Sql Server 2005 Express and RANU
Feed Title: Raymond Lewallen
Feed URL: /error.htm?aspxerrorpath=/blogs/raymond.lewallen/rss.aspx
Feed Description: Patterns and Practices, OOP, .Net and Sql
There are some new features around SQL Server Express 2005 (SSE)
which allow you to treat your database just like a file. You can add
the .MDF file to your project and then when you go to deploy your app
it travels with it like a file so you don't have to worry about setting
up a database on a server. This is similar to Access but with the power
of SQL Server. I believe this is how RANU (run as normal user) is
supposed to work. Each user on the machine gets their own instance
of SQL Express. The way RANU works is that it looks in the exe's
current folder for the .MDF file. When you debug and build your app in
VS the exe is actually run from a subfolder so VS has to copy the .MDF
to the same location. This requires you to put the .MDF in the project
so that the project system knows to copy the file on a build. So the
"short" answer is that there will be one copy to put it into your
project folder, and then another copy to the build location on build or
debug. There is a Copy to Output Directory property on the file which
allows you to specific if you want to do the copy everytime or just
when the .mdf file in the project changes. So at runtime if I have a 1 GB
database it is going to get copied around at that time. However, you can turn off this
functionality. This is also specific to the designtime features. Runtime will
work against an absolute path so you can avoid the copies if desired. It is expected
that most databases won't be that large so it works pretty well for getting
started with the feature. Thanks to Eric on the
Visual Basic Data Team at MS for the information on RANU!