Author : HASSAN MD TAREQ

Using EF data layer

  • For simplycity, we are gonna show how to use AdevntureWorks.Data in a console app
  • For complex appliction AdevntureWorks.Data can be used in Repository layer (process is same)

Using EF data layer in a console app

Step-1

Using EF Data Layer in A Console App Step 1

Step-2

Using EF Data Layer in A Console App Step 2

Step-3

Using EF Data Layer in A Console App Step 3

Step-4

Using EF Data Layer in A Console App Step 4

Step-5

Using EF Data Layer in A Console App Step 5

Step-6

Using EF Data Layer in A Console App Step 6

Step-7

Using EF Data Layer in A Console App Step 7

Step-8

Using EF Data Layer in A Console App Step 8

Step-9

Using EF Data Layer in A Console App Step 9

Step-10

Using EF Data Layer in A Console App Step 10

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using AdevntureWorks.Data;

namespace AdevntureWorks.ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var awDbContext = new AdventureWorksDbContext();

            Debug.WriteLine("List of persons");

            foreach (var person in awDbContext.Person.Take(10))
            {
                Debug.WriteLine($"{person.LastName}");
            }
        }
    }
}