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 .

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


Look at EntityFramework with code first deployments.

See this

Create the database and then use this tutorial : This should help

Need Your Help

When to use "assign" in smarty?

smarty assign

What is the difference between line #1 and line #2? Both are stored in template.tpl and both are working identically. Why should I use {assign} if direct assignment (line #2) works as well.

ResultSet Data of every row store in other array index

java resultset

I am new in JAVA, so kindly understand my question and please give your valuable and precise answer.