Table to Entity Mapping

c# entity-framework

Question

I already have an Entity Framework project. There are various entities in the Model1.edmx file that are pulled from the SQL Server database. In the SQL Server Database, I created a new table. And I updated Model.edmx with a new entity. Additionally, the newly created database does not appear in the table mapping when I attempt to map this new item to it. Please Assist.

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

Accepted Answer

Why not try using the update from database option when you right click the edmx file, rather than manually adding the object and attempting to map them. The model should automatically regenerate with the correct connections and linkages after you choose your freshly formed table.

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

Popular Answer

Manually mapping entities is a bad idea.

Follow these steps to create an entity and map those entities:

  1. When you do a right click on an edmx file, choose "Update model from database."
  2. By doing so, a window where you may choose and include a newly created table will appear.

Expand your.tt file after doing this to make sure the.cs file was automatically produced.

If this is not already built, right-click each.tt file and choose "Run custom tool" from the menu that appears. This will automatically create the necessary 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