I am using the EF in VS2010. I first created a DB and then choose create model from DB.. Then I go and choose Add Code Generation item.. everything looks good so far. Now I added a new table in my DB, I then choose update model from DB. This is still OK. How do I tell VS 2010 to generate a model file for that new table?
I end up deleting everything and and repeating the step over and over for every time I make a change to the database. ANy suggestions?
When you click on Add Code Generation item inside *.edmx it will create two files:
YourModel.Context.tt (produces a strongly typed ObjectContext for the YourModel.edmx)
YourModel.tt (responsible for generating a file for each EntityType and ComplexType in the YourModel.Context.tt)
When you update your *.edmx you just need to right click on YourModel.tt and choose Run Custom Tool.
More info:
Because you’re using such approach i would recommend that you move the YourModel.tt file into the separate Class Library project (hold the Shift key and drag and move it)
Modify:
string inputFile = @ “YourModel.edmx”; to
string inputFile = @ “..\YourNamespaceWhereEdmxIS\YourModel.edmx”;
in your YourModel.tt.
Change Custom Tool Namespace for your YourModel.Context.tt in the properties browser to match YourClassLibraryName
Regards.