How to: Synchronize Changes Between Entity Models and the Database Project

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

Starting with Visual Studio 11 Developer Preview, the Entity Data Model Wizard allows you to generate the model from an existing database project. You can then edit your model in the Entity Data Model Designer or make changes in the database project and synchronize the changes between the two. You can fine-tune how you want synchronization to happen. For example, you can specify different behaviors for synchronizing changes based on creating, deleting, or renaming entity types or properties in the model.

For information on how to create a database project, see How to: Create a New Database Project.

For information on how to generate the conceptual model from an existing database project, see How to: Generate Entity Data Models from an Existing Database Project.

Edit the entity data model and synchronize changes with the database project

To add a scalar property to an entity

  1. On the Entity Designer surface, right-click the entity, select Add New, then Scalar Property.

  2. Replace the auto-generated name for the new scalar property.

    By default, changes in the entity model are propagated back to the database project automatically.

  3. In Solution Explorer, expand the database project on which the model is based. Under the dbo folder, expand the Tables folder, then select .sql file that has the same name as the entity you edited.

  4. Double-click the .sql file to open the Table Designer. Notice that a new column has been added to the table.

To edit a scalar property of an entity

  1. Go back to the .edmx window.

  2. On the Entity Designer surface, right-click the scalar property of an entity, select Refactor Rename. In the Rename dialog type the new property name. Optionally, view the changes in the preview window before selecting OK and making them permanent in the referenced database project.

    Hh344282.note(en-us,VS.110).gifNote:
    Selecting Rename option just renames the property in the entity model and does not propagate the change to the database project.

  3. Go back to the .sql file. Notice that the column name has been updated accordingly.

To fine-tune synchronization settings

  1. Right-click an empty area of the design surface and select Sync Settings.

  2. On the Sync Settings tab, specify how you want for the Entity Data Model and the database project to interact.

Edit the database project and synchronize changes with the entity data model

  1. In Solution Explorer, select the database project on which the model is based. Expand the dbo folder, right-click the Tables folder and select Add, then Table.

  2. Replace the auto-generated name for the new table.

  3. The Table Designer opens. In the Columns Grid, add new columns to the table. For more information, see How to: Use the Table Designer to Manage Tables and Relationships.

  4. Return to the .edmx window. Notice that the new entity has been added to the model.

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft