Wednesday, May 29, 2013

How to manually add entity to edmx

Recently had to add entities manually to edmx file since using the "update model from database" feature kept erasing mappings.

The edmx was originally generated using Huagati edmx tool :  http://www.huagati.com/dbmltools/ which I didn't have.

Steps to manually table to edmx:

Note: you should have some entities in your edmx file already so you can follow their naming conventions and patterns.

1) Open the edmx file with a xml editor
2) navigate to the SSDL section and add a new EntitySet tag under EntityContainer
3) also in SSDL within EntityContainer, create a new EntityType tag
the property tags will match the column names for the database table


4) In CSDL, under EntityContainer, create an EntitySet tag
5) Now add the EntityType also under EntityContainer
6) Save and open in the designer so you can add the mappings in (map model to database fields).

Environment I used:

Visual Studio 2012
Entity Framework 5

Good references: 


No comments:

Post a Comment