dlght
dlght

Reputation: 926

How to create database from the C# code in MVC 4 project

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

Upvotes: 0

Views: 5858

Answers (2)

user3959430
user3959430

Reputation: 43

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

Upvotes: 1

Gjohn
Gjohn

Reputation: 1281

Look at EntityFramework with code first deployments.

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

Upvotes: 1

Related Questions