Sharing a database with two applications

Discussion in 'Databases' started by ekat, Sep 8, 2010.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I recently signed up for hosting and one database (sql). I plan to host at least one mvc 2 web app and one wcf service - both of which use databases. Since neither need much space I was planning to use the one database with a prefix to indicate which table is associated with which app.

    I was able to get mvc app's database (which is the standard ASP Membership) up and running by creating it locally and then importing the mdf file to create the tables I needed on the live database.

    Now I'm trying to get my other application working with the database. I am getting an error when I try to write to it, which I think is because the table doesn't exist in the database yet. Should the entities framework automatically create a database table if it doesn't exist, or do I need to write scripts to do that, or is there a way to import tables from an mdf file whiteout clearing the tables already in the database?

    Thanks!
     
  2. dmitri

    dmitri DiscountASP.NET Staff

    When you are attaching .mdf file or restore .bak backup to the database on the server, you are completely replacing the current database. If you need to add other objects (tables, store procedures, functions, etc) to your current database online, you will need to use a different technique such as scripting the objects on your local machine and then run the script inside your database on the server.
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page