ASP.NET MVC + Entity - How to map new tables

Asked

Viewed 503 times

1

Good morning,

I have a project using ASP.MVC + EF and mapped about 20 tables using the VS wizard (creating the ADO.NET Entity Data Model, selecting the database and the tables I want), but now I have 16 more tables to insert into the system and I can’t find an option to include them using automatic mapping (as in the first 20).

From what I’ve seen, some people indicate to exclude my class who owns the DbContext (created from the ADO.NET Entity Data Model) and recreate it, but I’m not sure if this is the ideal way, since the models at the beginning are already formatted with Data Annotations and are used in various controllers.

Is there any way to map new tables using the Wizard of Entity Data Model without the need to exclude DBContext created in the first mapping?

I’m using Visual Studio Community 2017 and Code First from Database mode.

1 answer

0


You can open the designer by right-clicking on your file .EDMX and selecting Open With -> ADO.NET Entity Data Model Designer inserir a descrição da imagem aqui Right click on the designer’s surface .EDMX and click on Update Model From Database. inserir a descrição da imagem aqui All entities are updated by default, new entities are only added if you select them.

  • Hello, Marconcilio Souza! Thank you so much for your help. In the case I mentioned above, I don’t have . EDMX because I used EF Code First from Database - so I searched, EDMX is generated when using Designer Centric (Model First and Database First). Anyway, to solve my problem I created the models at hand. Maybe it wasn’t the most agile form, but I was able to learn some important covenants that I hadn’t noticed until then. Thank you so much for your willingness to help! Hug!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.