Migrating an SQL database from 2014 to 2012 - mvc codefirst

I am developing a project with ASP.net-MVC and, as it first models, it automatically creates .mdf and .ldf database files. and the database is in the 2014 version. When I wanted to upload it to the host server, they told me that they did not support the upper version of 2012. Therefore, I need to transfer my database from the version from 2014 to 2012.

my database is not that 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 problem with mine database version did not happen. its still Product Version:12.0.2000.8

really appreciate your help. thanks

+5
source share
3 answers

You are developing a database based on the First model, so you have all the controls in generating / modifying the database.

You do not need to migrate the database, but in visual studio you can recreate the database in SQL Server 2012.

To create a database in sql 2012, follow the same steps as you to create a database for sql 2014 in visual studio, just for a reminder:

  • On the EDMX design surface, right-click → Create a database from the model. Follow the wizard and create a new connection to sql2012.

At the end of the wizard, a new database is created in SQL Server 2012.

  • Sql script is also automatically generated with a name, for example. model.edmx.sql, including all object DDLs and associations, ...

  • Output the script in VS, you can select the connection and execute the script on the new 2012 database server.

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

Update:

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

If the project does not have EDMX, this means that you did not use the ModelFirst approach, but you can use the MVC project template, which automatically creates a database at the beginning of the project.

An advantage of the First model is the ease of change and synchronization between the development environment and production for future changes.

You can redesign your project and add a ModelFirst approach, even if you created the database.

From there, you can re-create the database on sql 2012 server. I will describe a walkthrough to create your mode:

Creating a DataModel from an Existing Database in EntityFramework 6 For ModelFirst Approach

+1
source

The compatibility level must be installed on SQL Server 2012 (110) before the following steps https://www.mssqltips.com/sqlservertip/2810/how-to-migrate-a-sql-server-database-to-a-lower-version /

To change the compatibility level, go to the database properties-> Options-> Compatibility Level

When you run the script output, it should be run on the target server (2012). Backups of the latest versions cannot be restored in earlier versions.

0
source

Look here

The setup will change your database from 2014 to 2012.

0
source

Source: https://habr.com/ru/post/1257576/


All Articles