Table to Entity Mapping

c# entity-framework

Question

I already have a project in Entity Framework. The Model1.edmx file has several Entities which come from SQL Server Database. I added a new table in SQL Server Database. And I added a new entity in Model.edmx. And when I try to map this new entity with newly added database, that database does not show up in the table mapping. Help Please.

1
5
3/31/2016 4:39:39 AM

Accepted Answer

Instead of manually adding the entity and trying to map them; why dont you try to to use the update from database option when you right click the edmx file. Select your newly created table and the model should regenerate itself with proper associations and relationships.

3
6/22/2011 6:54:28 PM

Popular Answer

It is not a good idea to map entities manually.

To add an entity and map those follow the steps below -

  1. Right click on edmx file and select 'Update model from database'
  2. This will open a window where you can choose and add newly added table.

After doing this, expand your .tt file and ensure that .cs file has been auto generated.

If this is not created, right click on every .tt files and select 'Run custom tool' from the options. This will auto-generate required files.



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow