Reputation: 10163
How do you deploy a database when you deploy an ASP.NET MVC application to production?
I've created a standard ASP.NET MVC3 application that uses SQL Server 2008 (albeit Express) for my app. I'm using the standard forms authentication stuff that comes with ASP.NET MVC apps.
If I have to re-create my schema, for all my classes (i.e. the non aspnet_*
tables), then I have SQL scripts I can run against the production DB; but what about the aspnet_*
tables?
Or should I simply upload an ASP.NET MVC empty DB (~10MB) and then run my scripts against it to create my tables? Surely, there must be a better way.
(Once this is solved, I plan to use SQL scripts or DB migrations to handle changes; it's only the question of generating the initial database in production without uploading the ~10MB .MDF that I can't get around, because of the aspnet_*
tables.)
Upvotes: 2
Views: 4126
Reputation: 717
You can also deploy the db using Visual Studio.
Upvotes: 2
Reputation: 8667
You could run aspnet_regsql
utility on your (empty) production database to generate the aspnet_* tables. Check out the MSDN article on the utility.
Upvotes: 2
Reputation: 171491
You can use aspnet_regsql.exe, located under C:\Windows\Microsoft.NET\Framework[your framework] to generate the schema in your db.
Run:
aspnet_regsql.exe /?
and you will see all of the command-line options this executable takes. -A
lets you specify what features (i.e., tables) will get created. If you do not use roles, for example, you may just use -A mp
.
You can choose to have it modify your database directly, or instead create a script that you can run. Some details here: http://weblogs.asp.net/lhunt/archive/2005/09/26/425966.aspx
Upvotes: 4