Question

This is my first time asking something on this awesome website, so please, be polite with me if I'm breaking some rule.

So, here's my problem, I have developed a e-commerce software for a certain customer, in Asp.NET, MVC4. Then, I developed another e-commerce for a different customer, obviously starting from the last one. Now I have two similar e-commerce projects, differing only for some feature I had to add for the newer customer. The problem is that now, the old customer, wants me to update his e-commerce as well, adding the new features I already added for the other one; of course he doesn't want his data to be lost, so I have to migrate all the data stored in the old database, to an updated version, with a different scheme: for example, the new scheme has tables, relations and columns, not present on the old one.

Which is the best solution you suggest me to follow? Are there functions in sql server already, suitable for the purpose? Does the framework include some solution for this? Thanks in advance, and sorry for my poor english. If I have not explained correctly, I will be happy to give you more detail.

Was it helpful?

Solution

I do not know of a standard ASP.NET or SQL Server out-of-the box solution.

One solution is to update the database object definitions outside of the ASP.NET framework. There are a few solid software options that will compare the object definitions of your two databases and produce SQL code to bringer your older database in sync with your newer database.

What will this software do? For Example, if you had this table:

Table1 (id int primary key, col_one int)

and you need to alter the table to look like this:

Table1 (id int primary key, col_one int, col_two nvarchar(50))

then, the database compare software will either execute or print/display SQL code that looks like this:

Alter Table1 Add Column col_two

As always, be sure to create database backups before changing object definitions!

Are you using code first? If so, (at least temporarily) disable the default database migrations. More can be found here and here. This will prevent ASP.NET from dropping and re-creating your database if it finds any schema changes (I think it is better to receive an error than lose all of your data.)

OTHER TIPS

you have to build a little console application (try it before 2000 times in a testing db) that pull data from the old database and push it in the right place with the right new id's to let the data live in the new database structure.

i will suggest you to not use the "id" bigint autoincrement column, but to create in the first database a new "guid" column to uniquely-database-indipendent identification of every data and to point data themselves using guids instead of id.

hope this helps you.

good luck.

ps: sorry for my english too

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top