Model Browser in Entity Framework

Model Browser in Entity Framework:

In this article, I am going to discuss the Model Browser in Entity Framework Database First Approach in detail. Please read our previous article where we discussed the Entity Data Model (EDM) in detail.

Note: We are going to work with the same example that we created in our introduction to Entity Framework Database First Approach article. Please read our introduction to Entity Framework Database First article before proceeding to this article.

Model Browser in Entity Framework

The visual designer of the Entity Data Model does not display all the objects it creates. It only displays entities that are mapped to the database tables and views. As we know, we have created some stored procedures in our database. And while creating the Entity Data Model we have included those stored procedures as well. But if you look at the visual designer of Entity Data Model, then you will not find those stored procedures as shown in the below image.

Model Browser in Entity Framework

The Model Browser in Entity Framework gives you the information about all the objects and functions (stored procedures are created as functions) EDM has created.

What is the Model Browser?

The Model Browser is a Visual Studio tool that is integrated with the ADO.NET Entity Data Model Designer (Entity Designer). It provides conceptual and storage models tree view that is defined in a .edmx file. The Model Browser groups information into two nodes.

  1. The First node shows the conceptual model. By expanding the child nodes, you can view all entity types and associations in the model.
  2. The Second node shows the target database model. By expanding the child nodes, you can see which parts of the database tables, views, and stored procedures have been imported to the model.

Model Browser gives all the information about all the objects and functions created by the EDM. In order to open the Model Browser, right-click the empty surface of the EDM designer and select Model Browser from the context menu as shown in the below image.

Model Browser in Entity Framework Database First Approach

The Model Browser will appear in the area where you normally find Solution Explorer and Properties. The Model Browser contains all the information about the EDM, its conceptual model, storage model, and mapping information, as shown in the below image.

Model Browser in Entity Framework Database First Approach

As you can see in the above image, the Model Browser contains the following objects:

Diagrams: The Model Browser contains the visual diagrams of the EDM. You can see the default visual diagram created by EDM i.e. Diagram1. It is also possible to create multiple Visual diagrams for one EDM if the application has a large number of entities

Entity Types: The Entity Types lists all the class types which are mapped to the database tables.

Complex Types: Complex types are the classes that are generated by EDM to contain the result of stored procedures, table-valued functions, etc. These complex types are customized classes for different purposes.

Enum Types: Enum Types lists all the entities which are used as Enum in the entity framework.

Associations: Associations lists all foreign key relationship between the entity types.

Function Imports: Function Imports lists all the functions which will be mapped to stored procedures, table-valued functions, etc. Stored procedures and table-valued functions will be used as functions and not as entities in EF.

EF_Demo_DBModel.Store: It represents the database schema (SSDL) i.e. the database tables, views, functions, stored procedures, and the foreign key relationships between the tables. If you expand the child nodes you will see the following.

Model Browser in Entity Framework Database First Approach

In the next article, I am going to discuss the DbContext class in Entity Framework Database First Approach. In this article, I try to explain the Model Browser in Entity Framework Database First Approach and I hope you enjoyed Model Browser in Entity Framework article. Please give your valuable feedback and suggestions about this article.

Leave a Reply

Your email address will not be published. Required fields are marked *