none
Entity FrameworkUpdate Model from Database doesn't work RRS feed

  • Question

  • Hi ,

    I have created model from database,

    i alter the datatype nvarchar to int in the database table and update the model

    but there is no chnage in the model and giving error as

    member mapping specified is not valid ,the type EDM.string is not compatible to sql.int

    update model is working when i have added new column to database table.

    any solution

    thanks inadvance

    Monday, September 17, 2012 3:01 PM

Answers

  • Hi pradeepmanne;

    What you will need to do is go to the designer and select the table that was modified on the server and right click on it and select delete. Then right click on the design surface and select Update Model from Database... in the Add tab expand the Table and re-select the table you just deleted from the designer. Then click on the Finish button. The model should be in sync with the database now.

      

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Alexander Sun Tuesday, October 9, 2012 8:31 AM
    Monday, September 17, 2012 3:37 PM
  • Hi,

    The built-in update wizard for EF will update the SSDL layer of the model, but won't update the CSDL for many types of changes. In this case, you simply need to change the data type for the corresponding property from string to int in the designer. Removing the entity and re-adding it as suggested by Fernando works as well, but with the drawback that you may lose other customizations you may have done to that entity, and if it is part of an inheritance structure you may need to redo that as well.

    Alternatively, if you do a lot of model or db changes that need to be kept in sync, you may want to look at 3rd party tools for EF that can help you to keep the model layers in sync, and model in sync with the db. One such tool is the "model comparer" for EF in my add-in. You can see a short screencast of it here: http://www.youtube.com/watch?v=doqYOlcEAZM , and if you want to try it out you can download it and get a trial license from http://huagati.com/edmxtools/ 

    Hope this helps.

    Best regards,
    Kristofer


     

       Cool tools for Linq-to-SQL and Entity Framework 4:
     huagati.com/dbmltools - Visual Studio add-in with loads of new features for the Entity Framework and Linq-to-SQL designers
     huagati.com/L2SProfiler - Runtime SQL query profiler for Linq-to-SQL and Entity Framework v4

    • Marked as answer by Alexander Sun Tuesday, October 9, 2012 8:31 AM
    Monday, September 17, 2012 3:50 PM

All replies

  • Hi pradeepmanne;

    What you will need to do is go to the designer and select the table that was modified on the server and right click on it and select delete. Then right click on the design surface and select Update Model from Database... in the Add tab expand the Table and re-select the table you just deleted from the designer. Then click on the Finish button. The model should be in sync with the database now.

      

    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked as answer by Alexander Sun Tuesday, October 9, 2012 8:31 AM
    Monday, September 17, 2012 3:37 PM
  • Hi,

    The built-in update wizard for EF will update the SSDL layer of the model, but won't update the CSDL for many types of changes. In this case, you simply need to change the data type for the corresponding property from string to int in the designer. Removing the entity and re-adding it as suggested by Fernando works as well, but with the drawback that you may lose other customizations you may have done to that entity, and if it is part of an inheritance structure you may need to redo that as well.

    Alternatively, if you do a lot of model or db changes that need to be kept in sync, you may want to look at 3rd party tools for EF that can help you to keep the model layers in sync, and model in sync with the db. One such tool is the "model comparer" for EF in my add-in. You can see a short screencast of it here: http://www.youtube.com/watch?v=doqYOlcEAZM , and if you want to try it out you can download it and get a trial license from http://huagati.com/edmxtools/ 

    Hope this helps.

    Best regards,
    Kristofer


     

       Cool tools for Linq-to-SQL and Entity Framework 4:
     huagati.com/dbmltools - Visual Studio add-in with loads of new features for the Entity Framework and Linq-to-SQL designers
     huagati.com/L2SProfiler - Runtime SQL query profiler for Linq-to-SQL and Entity Framework v4

    • Marked as answer by Alexander Sun Tuesday, October 9, 2012 8:31 AM
    Monday, September 17, 2012 3:50 PM