locked
what is migration and when to use it RRS feed

  • Question

  • Hi , 

    Im actually creating my first EF using code 1st approach application.

    i wanted to know what is migration and when to use it ?


    Thank You , Shan Ali Khan

    Sunday, January 5, 2014 7:34 PM

Answers

  • Migrations provide a way of synchronising your model with the actual database when using code first. There is some good documentation on the Data Developer Center (see here and here).

    • Marked as answer by Fred Bao Tuesday, January 14, 2014 8:30 AM
    Monday, January 6, 2014 1:35 AM
  • Hello Shan,

    >> What is migration?

    Code First Migrations allow for database changes to be implemented all through code. Through the use of Package Manager Console (PMC), commands can be used to scaffold database changes. And there are two ways to use it: manual migrations and automatic migrations.

    For how to use code first with manual migrations, please refer to link below:

    http://msdn.microsoft.com/en-us/data/jj591621.aspx#model

    For how to use code first with automatic migrations, please refer to link below:

    http://msdn.microsoft.com/en-us/data/jj554735.aspx

    >>When to use it?

    When we did some changes with the entities classes (for example, adding a property) and the navigation between them and we did not want to delete the existed database and re-created it, then we could use the migrations.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Tuesday, January 14, 2014 8:30 AM
    Monday, January 6, 2014 1:44 AM

All replies

  • Migrations provide a way of synchronising your model with the actual database when using code first. There is some good documentation on the Data Developer Center (see here and here).

    • Marked as answer by Fred Bao Tuesday, January 14, 2014 8:30 AM
    Monday, January 6, 2014 1:35 AM
  • Hello Shan,

    >> What is migration?

    Code First Migrations allow for database changes to be implemented all through code. Through the use of Package Manager Console (PMC), commands can be used to scaffold database changes. And there are two ways to use it: manual migrations and automatic migrations.

    For how to use code first with manual migrations, please refer to link below:

    http://msdn.microsoft.com/en-us/data/jj591621.aspx#model

    For how to use code first with automatic migrations, please refer to link below:

    http://msdn.microsoft.com/en-us/data/jj554735.aspx

    >>When to use it?

    When we did some changes with the entities classes (for example, adding a property) and the navigation between them and we did not want to delete the existed database and re-created it, then we could use the migrations.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Tuesday, January 14, 2014 8:30 AM
    Monday, January 6, 2014 1:44 AM