find a location for property in a new city

Thursday 17 June 2010

Update minor change to database in your Entity Data Model

I added a new column to a table in the database and couldn't seem to get these changes reflected in my Entity Data Model using Entity Framework 4. There is a function I can use in the context menu called "Update Model from Database..." but that seems overkill. I just want one new column mapped in my entity data model.

I didn't want to use the 'Update Model from Database' since it will update every table and view in my model, reverting all the entity and property names to the database naming convention and breaking all my referencing code. Too much pain for what should be quite a simple change? Yes, I think so.


As an example let's say you have added a varchar(50) column called MyDbColumn to MyDbTable that currently has an entity modelled called MyEntity that hasn't recognised this column which you want to be called MyProperty.

Let's also say you have added MyProperty of type String with MaxLength set to 50 to your MyEntity entity. If not, do that. Now the tough bit: Mapping it to the database without a full update.

Time to leave the comfort of the UI.
  1. Right click your edmx file in the Solution Explorer
  2. Select 'Open With...'
  3. Select 'XML (Text) Editor' and click OK (you may be asked to close any open instances of the edmx file)
  4. Search for where is says <EntityType Name="MyDbTable">
  5. Add the property <Property Name="MyDbColumn" Type="varchar" MaxLength="50" />
  6. Search for <EntitySetMapping Name="MyEntity">
  7. You can find all your other mapped properties within a 'MappingFragment' element.
  8. Add your new mapped column <ScalarProperty Name="MyPropertyName" ColumnName="MyDbColumnName"/>
  9. Save & Build

If you now re-open your edmx file in the designer and take a look at the Mapping Details for MyEntity you will see that MyProperty is mapped to MyDbColumn in MyDbTable. Lovely stuff!

Follow britishdev on Twitter


  1. Thanks a lot . very useful

  2. Nice post, really helped me. keep up the good work.

  3. Thank you so much, it saved ton of effort!

  4. thank you sir, such a simple thing that Microsoft forgot.

  5. I'm keen a put up. It happens to be fantastic to ascertain most people verbalize out of your spirit not to mention ability on that fundamental topic area are generally comfortably found. ideas viewpoint online site.
    deluxe over table

  6. what am I missing?
    I followed these instructions (in fact, tried 3 times). I get an error:

    running transformation: Content not valid. The conceptual side Member or Property 'myfield' specified as part of this MSL does not exist in MetadataWorkspace.

    1. After you do this, open the EDMX in the designer and manually add each property:
      1. Find the table entity in the EDMX diagram
      2. Right-click on the entity and choose Add New -> Scalar property (or other type of property)
      3. Right-click on the newly added property and choose Properties
      4. As needed, you can change the Name, Nullable, Type, etc.

  7. In addition, they are durable, with an average lifespan of up to seven times that of most magnetic data storage devices, making them ideal for storing permanent data such as photographs and music. Self Storage

  8. In fact, it's embedded into the end program. SQLite is widely supported by various browsers, operating systems, embedded systems and many other applications. kpi dashboards

  9. A database helps manage information to produce meaningful results. Travel agents are among the most experienced users of dashboards

  10. Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.

    zuan education

  11. Only the computers which have a legitimate IP address are permitted by the server of the company to access the database.Database Diagram Tool

  12. This preparation helps you in executing examination of huge information on a huge scale. It additionally prepares you on the most proficient method to impart your discoveries in a convincing way. ExcelR Data Science Courses

  13. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! how to install tensorflow anaconda

  14. Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post. Tableau Data Blending

  15. Excellent Blog! I would like to thank for the efforts you have made in writing this post. I am hoping the same best work from you in the future as well. I wanted to thank you for this websites! Thanks for sharing. Great websites!
    ai training in varanasi

  16. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    ai training in mysore

  17. This is an excellent post I have seen thanks to sharing it. It is really what I wanted to see hope in future you will continue for sharing such an excellent post. I would like to add a little comment data analytics course in hyderabad

  18. Very informative post! Here is a lot of information that can help any business start a successful social media campaign!
    Data Science Course

  19. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

    ai course in surat

  20. I have to search sites with relevant information ,This is a
    wonderful blog,These type of blog keeps the users interest in
    the website, i am impressed. thank you.
    Data Science Course in Bangalore | Data Science Training in Bangalore

  21. You can utilize web indexes to assist you with finding dependable entry near me

  22. I see some amazingly important and kept up to length of your strength searching for in your on the site
    artificial intelligence courses in delhi

  23. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. This article inspired me to read more. keep it science courses

  24. Cloud Computing Projects

    Networking Projects

    Final Year

    Projects for CSE

    JavaScript Training in Chennai


    Training in Chennai

    The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals,

    Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer.

    Angular Training

  25. Very nice blog. A great piece of writing. You have shared a true worthy blog and keep sharing more blogs with us. Thank you.
    Data Science Training in Hyderabad

  26. Here I saw several articles and posts published on this site, I am more interested in some of them, will provide more information on these topics in future articles.Manual Testing training onlineManual Testing Online TrainingQA training OnlineSoftware testing Online Courseselenium training online courseqa testing online coursepython training in hyderabad