开发者

Mapping Table to Entity

开发者 https://www.devze.com 2023-03-14 14:22 出处:网络
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 ne

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 -

  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.

0

精彩评论

暂无评论...
验证码 换一张
取 消