共用方式為


Building the Business Logic Layer classes with Entity Framework and Code First

If you ask a developer how to become “Wealthy” in an object-oriented way, they might tell you that it´s “Inheritance”. One of the most important things for a Developers is to think in an object oriented Fashion.  In his third video, Paul Cociuba, will take us through a Framework called ORM…


Data access in modern data driven applications goes through an ORM – an Object relational Mapper. This is an abstraction layer that allows developers to continue to think in an object oriented fashion while interacting with persistent storage – the SQL database. Entity Framework is one of the most popular ORM frameworks that exists on the web which has high Downloads on NuGet. In this video, we will look in how Entity Framework can be used, to construct the business logic layer objects needed, to allow the application to easily interact with the database.

For your convenience, here’s the video timeline (note that it will launch a new browser Windows):

  • [1:00]Design paradigms with Entity Framework. Entity Framework allows three design paradigms to account for different development scenarios.
    • Entity Framework
    • Design First Database
    • First Code First
  • [4:10]Building the POCO (Plain Old CLR / C# Objects) classes: these are simple classes that declare properties of various types. Entity Framework leverages these to generate the database table structure from.
  • [7:15]Coding the relations between the POCO classes –Entity Framework has to create relations between different tables in a database. For this we need to create special properties to link these objects together.
  • [10:20]Linking the classes to the new database that will be generated by Entity Framework will be done by two special classes called ProductContext and ProductModelInitializer.
  • [14:20]The ProductModelInitializer class allows Entity Framework to seed the database with sample database when the database is first created – the first time the application launches.
  • [17:35]Global.asax modifications to finish the business logic layers. To finish the business logic layer, we will modify the Application_Start event handler, which runs when the application launches.

In the next video, we will look at how to use the model classes to extract data from the database and present it via ASP.net webforms. 

References:


Original content from Paul Cociuba; posted by MSPFE Editor Aydin Aslaner

Comments

  • Anonymous
    February 26, 2015
    POCO stands for "Plain Old CLR Object", not "Plain Old C# Object"