views:

17

answers:

1

I've been playing around with hosting on discountasp.net and am in the process of hosting my second web app. Being that discountasp charges you per database and not per sql server or total space used by all of your databases, both apps need to share one database

I need to create all of the tables from the database used by the second application in the live database. I can't just import the mdf file because that would drop all of the data already stored by the first application. Is there a way to automatically generate the scripts or simple sql commands to create the tables in the mdf file from within visual studio?

Also, since multiple applications will ultimately use the same database I'd like to add a prefix to each table names - like App1_Table1. Is there a simple way to rename tables inside VS 2010? Further is there a way to rename the tables but have the entities framework ignore the prefix when generating it's classes?

Thanks for your help, your answers will save me a ton of time I could be programming with :).

A: 

There are many options available to you.

In Visual Studio there's database schema compare functionality.

ScriptDb is a simple console app written in C# that uses SQL Management Objects (SMO) to script all the objects in a database. It will work against any SQL Server 2000 or 2005 database. It creates a directory tree structure with a similar hierarchy to that in Object Explorer in SSMS, with a separate file for each object.

There's also an option to script database objects from SSMS. Right-click on a database -> Task -> Generate scripts.

Denis Valeev
Great, thanks !
evan

related questions