0

I am working on MVC 4 web app using Entitiy framework 5. I have an users membership database and an administration which divides data of the website into factories and for each factory i need a different database. Here is where my problem comes :

I need to create a new database into the master with predefined tables and stored procedures with sql script from the C# code. But for this i cannot use entity framework as i saw. I have found some ways with ado sql command calls, but it requires to mix up EF with raw ado.net .

My question is:

Is there a way to execute sql script for creating a whole database from the C# code using EF5 somehow ?

For now the only way that i have found is this : Code to create & connect to a SQL Server database: Whats wrong with it?

Any suggestions would be heplful. Thanks

Community
  • 1
  • 1
dlght
  • 1,406
  • 1
  • 18
  • 35
  • 1
    http://stackoverflow.com/questions/4833650/create-new-database-programmatically-in-asp-net-mvc-application maybe helps you – MustafaP Feb 03 '14 at 15:21

2 Answers2

1

Look at EntityFramework with code first deployments.

See this http://msdn.microsoft.com/en-us/data/jj193542.aspx

Gjohn
  • 1,261
  • 1
  • 8
  • 12
1

Create the database and then use this tutorial : http://msdn.microsoft.com/en-us/data/jj200620.aspx. This should help

user3959430
  • 43
  • 1
  • 5