Ssocial.it Web Agency
Ssocial.it Web Agency

Reputation: 81

I can update database table from edmx model?

Is possible update database table from edmx model, for example if I create a new field in edmx diagram to a table, I want update corresponding mapped table in database adding this new field ... in visual studio menu I find the voice "update model from database" and "create database from model" , but I not find "update database from model"...

Upvotes: 0

Views: 394

Answers (2)

David Browne - Microsoft
David Browne - Microsoft

Reputation: 89371

In the EF EDMX "Model-First" workflow you always generate a full database DDL script, and for incremental changes use a schema-compare tool like SSDT to create the change script.

See eg https://learn.microsoft.com/en-us/ef/ef6/modeling/designer/workflows/model-first#5-dealing-with-model-changes

It's not a very popular or useful workflow, and the tooling for incremental updates was just never built. The vast majority of EDMX users do a database-first workflow with no customization of the EDMX.

But you should really stop using EDMX. The graphical designer seems simpler to begin with, but using code-based mapping is simpler in the long run.

Upvotes: 1

Pinch
Pinch

Reputation: 4207

I don't believe Edmx (database fist) works that way, at least, out of the box. You need to use code first, and enable migrations. Edmx is nothing more than mapping to your data, that doesn't tie into migrations. I believe there is a way to auto-generate your code first as well using visual studio...just like the Edmx.

Upvotes: 0

Related Questions