Edmx File On Visual Studio

On April 2nd, 2019 Microsoft released their newest Visual Studio 2019. As a developer who works with Visual Studio daily, I immediately downloaded the newest IDE and started to use. I enjoyed it from the start and the small UI differences work great. But this post is not about how it works but about a feature that is not working, hopefully yet.

After modifying an EDMX in Visual Studio 2019, it saves the EDMX properly but does not generate the C# files. This is a database first functionality, is there a new trick in VS2019 to actually gen. Expand the.edmx file in the solution explorer and open two important files,.Context.tt and.tt, as shown below: School.Context.tt: This T4 template file generates a context class whenever you change the Entity Data Model (.edmx file). You can see the context class file by expanding School.Context.tt.

Edmx file on visual studio download

In one of my projects we are still using a database first approach with an EDMX file in Entity Framework. We generate SQL scripts for updating our database and then we update our EDMX file, in a separate C# Class project. We use the normal EDMX database first approach by following the next few steps after updating tables or columns in our development database.

  1. Open EDMX file
  2. Right click file and select ‘Update Model from Database’
  3. I then choose my Database Objects and Settings and Click finish.
  4. Then my EDMX file is updated and I can save my file.

In Visual Studio 2017 saving my EDMX file also updated corresponding files under Model.TT. But with the introduction of Visual Studio 2019 only the .diagram file is being updated. This causes an issue because your new tables and columns are not accessible through Entity Framework Database Context. I struggled with this issue for a while and since Visual Studio had just come out, I could not find much information regarding the issue on the internet. I tried removing the EDMX and recreating it but no effect. It was also not a strategy I wanted to do every time I updated our database.

I finally came across a solution about EDMX not updating in a version of Visual Studio dating back to 2013. I tried it in my solution, and it worked. I now must execute a few additional actions before my EDMX project is successfully updated for use. I hope the following steps will become obsolete once again after a next update of Visual Studio 2019.

Solution

I open the sub files of my Model.edmx file which contains files with the following extensions.

Edmx
  • Model.Context.tt
  • Model.Designer.cs
  • Model.edmx.diagram
  • Model.tt

Edmx File In Visual Studio 2015

I right click each of the files with the right click on my mouse and then select ‘Run Custom Tool’. Executing these steps will update all corresponding files so they can be used. I believe only the Model.tt file needs to be used by ‘Run Custom Tool’ but I have decided to run them all in case I missed something.

I hope this will help people that have run into the same issue in Visual Studio 2019 or any other version of Visual Studio. And I hope Microsoft will fix this issue in one of the upcoming updates.

-->

Entity Framework is an object-relational mapping technology that enables .NET developers to work with relational data by using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write. Entity Framework is the recommended object-relational mapping (ORM) modeling technology for new .NET applications.

Entity Framework Tools are designed to help you build Entity Framework (EF) applications. The complete documentation for Entity Framework is here: Overview - EF 6.

File

Note

Edmx File Visual Studio 2019

The Entity Framework Tools described on this page are used to generate .edmx files, which are not supported in EF Core. To generate an EF Core model from an existing database, see Reverse Engineering - EF Core. For more information on the differences between EF 6 and EF Core, see Compare EF 6 and EF Core.

With Entity Framework Tools, you can create a conceptual model from an existing database and then graphically visualize and edit your conceptual model. Or, you can graphically create a conceptual model first, and then generate a database that supports your model. In either case, you can automatically update your model when the underlying database changes and automatically generate object-layer code for your application. Database generation and object-layer code generation are customizable.

Update Edmx File Visual Studio 2019

The Entity Framework tools are installed as part of the Data storage and processing workload in the Visual Studio Installer. You can also install them as an individual component under the SDKs, libraries, and frameworks category.

These are the specific tools that make up Entity Framework tools in Visual Studio:

  • You can use the ADO.NET Entity Data Model Designer (Entity Designer) to visually create and modify entities, associations, mappings, and inheritance relationships. The Entity Designer also generates C# or Visual Basic object-layer code.

  • You can use the Entity Data Model Wizard to generate a conceptual model from an existing database and add database connection information to your application.

  • You can use the Create Database Wizard to create a conceptual model first and then create a database that supports the model.

  • You can use the Update Model Wizard to update your conceptual model, storage model, and mappings when changes have been made to the underlying database.

    Note

    Starting with Visual Studio 2010, Entity Framework tools do not support SQL Server 2000.

The tools generate or modify an .edmx file. This .edmx file contains information that describes the conceptual model, the storage model, and the mappings between them. For more information, see EDMX.

Entity Framework Power Tools help you build applications that use the Entity Data Model. The power tools can generate a conceptual model, validate an existing model, produce source-code files that contain object classes based on the conceptual model, and produce source-code files that contain views that the model generates. For detailed information, see Pre-Generated Mapping Views.

Related topics

TitleDescription
ADO.NET Entity FrameworkDescribes how to use Entity Data Model Tools, which Entity Framework provides, to create applications.
Entity Data ModelProvides links and information for working with data that is used by applications built on Entity Framework.
Entity Framework (EF) Documentation)Provides an index of videos, tutorials, and advanced documentation to help you make the most of Entity Framework.
ASP.NET 5 Application to New DatabaseDescribes how to create a new ASP.NET 5 application by using Entity Framework 7.

See also