Search code examples
visual-studio-2012entity-framework-5entity-framework-designer

How to override DbContext.Seed() when using the Visual Studio Model Designer


I just started to play around with EntityFramework. In VS2012 I can use the designer which nicely creates all the boilerplate code. However, I am now at a point where I wanted to start playing with overriding DbContext.Seed() to initialize the database with some data. While there is this quite easily done writing the DbContext myself, I was not able to find a way to do this from within the designer. It seems to be no option to modify the Designer created 'Context' class. The comment at the top of the file tells me, that all manually added code will be lost when the file is regenerated.

Am I missing something? Can someone please point me in the right direction. How can I do all the nice more advanced things and still continue to use the designer.


Solution

  • try to find a package in Nuget there will be a ready solution to connect. Read more here http://nugetmusthaves.com/Tag/POCO or search in google poco Nuget.