Search code examples
c#visual-studio-2012entity-framework-6

How to Rename DBContext in Entity Framework 6


I had an issue with EF not pulling in the Foreign Key relationships when doing an Update Model From Database. So I just deleted the .edmx file and regenerated it. The problem is that my context type was named InventoryMgmtContext, and now I am getting the error

The type of namespace InventoryMgmtContext could not be found.

Where/how can you rename the context?


Solution

    1. Open the EDMX diagram, right click the background, and click "Properties":

    enter image description here

    1. Change the Entity Container Name value to the name you want:

    enter image description here

    1. Save the EDMX.