none
What is the best methodology to follow when making changes to the EF model? RRS feed

  • Question

  • Hi,

    VS2013, SQL Server 2012 Express LocalDB, EF 6.0, VB, desktop application

    I've read several posts about how to handle schema changes and most of them include warnings that the method may not be reliable (I'm not sure why one would recommend a method and then give a disclaimer, but it is what it is).  I'd like to get a definitive answer on a bullet-proof methodology to ensure my end user's application makes a reliable transition when there is a schema change to the model.  I list here the steps it seems I must consider.  If I've missed any, please also inform:

    (1) From the first time the application is installed, it should have already moved all downloaded database files to a separate known location, most likely some sub-folder in <user>\App Data.

    (2) When there's a schema change, the new database file(s) must also be moved into the location in item (1) above.

    (3) The application must check to see if the new database file(s) have been loaded, and if not, transfer the data from the old database file(s) to the new database file(s).

    (4) Then the application can operate using the new schema.

    This may seem basic, but for those of us who haven't done it, it seems pretty important.

    Now, regarding item (3), that's where there seems to be a lot of discussion about how to do this.  I'd like to understand the various ways it can be done, and which is best.

    (1) Do the transfer in a 'one-time use' application method, i.e. do it in application code.

    (2) Do the transfer using some type of 'one-time use' SQL query.  If this is the best way, can you provide some guidance if there are different alternatives for how to perform this in SQL, and where to learn/see examples?

    (3) Some other method?

    Thanks.

    Best Regards,

    Alan


    • Edited by Alan Wheeler Tuesday, August 12, 2014 4:02 PM clarifications
    Tuesday, August 12, 2014 3:56 PM

Answers

  • What you have here are not EF issues, and they are deployment issue in how you address SQL Server. So you have an application that uses a new database and table schemas, which should have been addressed in development when you pointed the application using EF to the new schemas and tested against it. The deployment of the application using the new schemas and EF are not the issue, becuase once you deploy the application, the database needs to be correct beforehand.

    And the deployment of the new database and data transfer between the old database to the new database you must address before the application is deployed.

    For what you must do with the database, you need to go to the horse's mouth and get the information on what and how to do it, which you are not going to get (I don't think) in the EF forum. You need to post to the MS SQL Server forum and talk with DBA(s) who have done it.

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver

    • Marked as answer by Alan Wheeler Wednesday, August 13, 2014 3:00 PM
    Tuesday, August 12, 2014 6:46 PM
  • I will repost this in an SQL forum as you have indicated.

    I'm not able to delete this post, but if the moderator wants to keep it, this is the post I transferred the questions into.

    Thanks.

    Best Regards,

    Alan

    • Marked as answer by Alan Wheeler Wednesday, August 13, 2014 3:00 PM
    Wednesday, August 13, 2014 3:00 PM

All replies

  • What you have here are not EF issues, and they are deployment issue in how you address SQL Server. So you have an application that uses a new database and table schemas, which should have been addressed in development when you pointed the application using EF to the new schemas and tested against it. The deployment of the application using the new schemas and EF are not the issue, becuase once you deploy the application, the database needs to be correct beforehand.

    And the deployment of the new database and data transfer between the old database to the new database you must address before the application is deployed.

    For what you must do with the database, you need to go to the horse's mouth and get the information on what and how to do it, which you are not going to get (I don't think) in the EF forum. You need to post to the MS SQL Server forum and talk with DBA(s) who have done it.

    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/home?category=sqlserver

    • Marked as answer by Alan Wheeler Wednesday, August 13, 2014 3:00 PM
    Tuesday, August 12, 2014 6:46 PM
  • I will repost this in an SQL forum as you have indicated.

    I'm not able to delete this post, but if the moderator wants to keep it, this is the post I transferred the questions into.

    Thanks.

    Best Regards,

    Alan

    • Marked as answer by Alan Wheeler Wednesday, August 13, 2014 3:00 PM
    Wednesday, August 13, 2014 3:00 PM
  • Hi Darnold,

    I wanted to add a final comment to this thread.

    I posted this issue in the SQL Server > SQL Server Tools forum at this link to this post.

    I still have much learning to do, but it appears the later versions of EF begin to add tables to the model that are intended to support whatever methodology is chosen to manage schema changes.

    Best Regards,

    Alan


    • Edited by Alan Wheeler Wednesday, August 20, 2014 7:42 PM typo
    Wednesday, August 20, 2014 7:41 PM
  • Thanks for the reply.....
    Wednesday, August 20, 2014 7:58 PM