Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Migrate SQL database from 2014 to 2012 version - mvc codefirst

I'm developing a project with ASP.net-MVC and as it's Model first, it generates the .mdf and .ldf files of database automatically. and database is in version of 2014. when I wanted to upload it on host server they told me that they don't support upper version of 2012. so I need to migrate my data base from 2014 to 2012 version.

my data base is not that much big. and I follow this article https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version/ step by step but no diffrence happend to my database version. its still Product Version:12.0.2000.8

really appreciate you'r help. thanks

like image 910
neda Derakhshesh Avatar asked Oct 30 '22 19:10

neda Derakhshesh


1 Answers

You develop the database based on the Model First, so you have all control in generation /modifying the database.

You needn't to migrate the database, but in visual studio you can re-generate the database in sql server 2012.

To Generate the database in sql 2012, do the same steps you follow to generate database for sql 2014 in visual studio, just for reminding:

  • In the EDMX design surface, right click ->Generate database from the model Follow the wizard and create a new connection to sql2012.

At end of the wizard, a new database is created in sql server 2012.

  • Sql script is also auto generated named e.g. model.edmx.sql including all DDL of the Entity and associations,...

  • Exute that script within VS, you can select the connection and executing the script in the new database server 2012.

  • For the data, you can use the bcp utility or the export wizard in SSMS.

Update:

In the Model First approach, you create a diagram that will be automatically converted to a coded model and the model is saved in EDMX (xml file).

If there is no EDMX in the project, it means that you didn't use the ModelFirst approach, but you may used a template of MVC project which auto generate database at the start of the project.

The benefit of the Model First is the ease of change and sync between development Environment and the production for future changes.

You can re-engineer your project and add ModelFirst approach even you created a database.

From there you can re-create the database in the sql server 2012. I describe step by step tutorial to build your mode:

Building DataModel from Existing Database in EntityFramework 6 For ModelFirst Approach

like image 135
M.Hassan Avatar answered Nov 09 '22 12:11

M.Hassan