Visual Basic 2015 Unleashed by Alessandro Del Sole

Visual Basic 2015 Unleashed by Alessandro Del Sole

Author:Alessandro Del Sole [Del Sole, Alessandro]
Language: eng
Format: azw3
Publisher: Pearson Education
Published: 2015-07-25T04:00:00+00:00


* * *

The content of the MDL is quite simple, in that each ScalarProperty represents an entity’s property and establishes mapping between the property and the related column name in the database table.

Understanding the DbContext Class: The Visual Basic Mapping

Schemas in the Entity Data Model have a Visual Basic counterpart that enables you to write code to work against entities. To understand this, enable the View All Files view in Solution Explorer and expand the Northwind.edmx file. You will see two files with a .tt extension, Northwind.Context.tt and Northwind.tt. Files with a .tt extension are templates that Visual Studio uses for code generation and that are useful to the IDE to generate classes that allow developers to interact with the object model. Regardless of their content, which you are not required to understand for this chapter, start expanding the Northwind.Context.tt file, which contains another file called Northwind.Context.vb. Similar to the DataContext class in LINQ to SQL, the ADO.NET Entity Framework provides a class named System.Data.Entity.DbContext. This class, also referred to as the object context, is also the basis of the Code First pattern; It acts as a reference to the Entity Data Model and encapsulates the entities’ definition so that you can work with entities. It is also responsible for opening and closing connections, persisting data, keeping track of changes, and persisting data back to the database. DbContext is just the base class (as the DataContext is in LINQ to SQL) that every entity data model inherits from. Listing 26.4 shows how the object context is defined in our specific scenario.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.