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 i开发者_JAVA百科n 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.
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.
It is not a good idea to map entities manually.
To add an entity and map those follow the steps below -
- Right click on edmx file and select 'Update model from database'
- 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.
精彩评论