1

is it possible to change database tables (e.g adding a field in a particular table) in an application using Entity framework.??

My application used an existing database to generate a model nd entity classes out of that database, if now I want to change tables in my existing database , how can I do that using Entity framework, so that:

  1. Changes are saved in previously generated Entity classes
  2. Changes are saved in database also.
Sana.91
  • 1,999
  • 4
  • 33
  • 52

1 Answers1

1

Well you'll either have to change the database or the model classes.. If you don't want to update both manually, you could just update the database DDL and then generate the Entity model again.

dev_feed
  • 689
  • 2
  • 7
  • 25
  • right, but be careful with navigation properties whose names are automatically generated. if you add another foreign key pointing to same table properties can get mixed. keep that in mind. – Andrew Apr 10 '14 at 15:10
  • @Andrew Is'nt there any way i can do it through code? like migrations options in code first. Does the same Enable Migration option implies to Database First also? – Sana.91 Apr 10 '14 at 15:53
  • 2
    You are directly dependent on your database with Database First. Although I can be mistaken, but updating the Database and then going to EDMX model viewer and using Update Model Wizard is the only right way to go. http://msdn.microsoft.com/en-us/library/vstudio/cc716705%28v=vs.100%29.aspx – Andrew Apr 10 '14 at 16:08