none
How to update the model and DB after modifying an entity in the designer? RRS feed

  • Question

  • Hey there,

    I have a simple question that I'm hoping someone knows the answer to.  I've done the following:

    - Created a model using the "model-first" method, and then used the "Generate Database from Model..." feature in the designer.

    - I manually created an empty database, then executed the generated SQL against the database.

    - Everything seems to have worked fine.  However, I now add a new scalar property to an entity.

    Questions:

    Q1.  How do I update the code model?  When I select "validate" on the designer, or run my application, I get a "Error 11009: property 'Xyz' is not mapped' and 'Error 3004: Problem in mapping fragments starting at line 123: no mapping specified..."

    Q2.  How do I update the database?  Can the designer create the required UPDATE statements, as well DROP/ADD keys, etc?

     

    Thank you very much.

    Matt

    Monday, August 22, 2011 4:28 PM

Answers

  • Q1: this is happening because there are three schemas in the EDMX file (CSDL - conceptual/SSDL - storage/MSL - mappings). When you are interacting with the designer surface (the boxes and lines), you are modifying the CSDL - conceptual layer. The property that you added has no value yet since you haven't added the corresponding column to the database and mapped it appropriately. The error indicates that there are no corresponding MSL - mappings or SSDL - storage constructs. You can verify this by looking at the Model Browser or the Table Mappings (both available through right-clicking on the diagram). So to fix this, you will have to run 'Generate Database from Model' again. Note that this will overwrite the SSDL and MSL and create drop/create DDL statements for your database... (see below)

    Q2: If you want incremental updates to the database (without modifying existing data or schema), take a look at the database generation power pack (http://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87) or Kristofer's Huagati DBML/EDMX tools: http://www.huagati.com/dbmltools/ 

     

    -adi


    Adi Unnithan | Software Design Engineer | SQL Server Developer Tools | Please mark the post as answered if it sufficiently answers your question
    • Marked as answer by OceanMorning Monday, August 22, 2011 7:50 PM
    Monday, August 22, 2011 7:44 PM

All replies

  • Q1: this is happening because there are three schemas in the EDMX file (CSDL - conceptual/SSDL - storage/MSL - mappings). When you are interacting with the designer surface (the boxes and lines), you are modifying the CSDL - conceptual layer. The property that you added has no value yet since you haven't added the corresponding column to the database and mapped it appropriately. The error indicates that there are no corresponding MSL - mappings or SSDL - storage constructs. You can verify this by looking at the Model Browser or the Table Mappings (both available through right-clicking on the diagram). So to fix this, you will have to run 'Generate Database from Model' again. Note that this will overwrite the SSDL and MSL and create drop/create DDL statements for your database... (see below)

    Q2: If you want incremental updates to the database (without modifying existing data or schema), take a look at the database generation power pack (http://visualstudiogallery.msdn.microsoft.com/df3541c3-d833-4b65-b942-989e7ec74c87) or Kristofer's Huagati DBML/EDMX tools: http://www.huagati.com/dbmltools/ 

     

    -adi


    Adi Unnithan | Software Design Engineer | SQL Server Developer Tools | Please mark the post as answered if it sufficiently answers your question
    • Marked as answer by OceanMorning Monday, August 22, 2011 7:50 PM
    Monday, August 22, 2011 7:44 PM
  • Thanks Adi, this is very helpful.
    Monday, August 22, 2011 7:50 PM