AliRıza Adıyahşi
AliRıza Adıyahşi

Reputation: 15866

In Visual Studio 2012, when you add an ADO.NET Entity Data Model (*.edmx)?

In Visual Studio 2012, when you add an ADO.NET Entity Data Model (*.edmx), it includes the T4 templates for the context and model classes as sub-items of the EDMX file. For example, if you add MyModel.edmx, it will have 4 sub-items as follows:

  1. MyModel.Context.tt
  2. MyModel.Designer.cs (in C# projects)
  3. MyModel.edmx.diagram
  4. MyModel.tt (model classes)

Question: When I change database, then I can update MyModel.Context automaticaly. If I change any model class (adding/deleting/updating any models or its properties) that is in MyModel.tt, Does database change automaticaly?

Upvotes: 0

Views: 811

Answers (2)

bujarm
bujarm

Reputation: 9

The Database changes automatically only if you're using Code First approach, which you're not, since you're using EDMX. Once you use EDMX you are using either Model First or Database First.

If you want your Database to change automatically, than you'll have to switch to Code First.

Upvotes: 0

omer schleifer
omer schleifer

Reputation: 3935

No it does not. the edmx file can be used to generate a new db schema, just right click on the demx designer -> choose generate db from model.

to update an existing model see:

Entity Framework 4 - Update database schema from model. Without wiping the table data

Upvotes: 1

Related Questions