• Entity Framework Tutorial Basics(4):Setup Entity Framework Environment


    Setup Entity Framework Environment:

    Entity Framework 5.0 API was distributed in two places, in NuGet package and in .NET framework. The .NET framework 4.0/4.5 included EF core API, whereas EntityFramework.dll via NuGet package included EF 5.0 specific features.

    Entity Framework5

    This has been changed with EF 6.0 which is included in EntityFramework.dll only and is not dependent on .NET framework.

    Entity Framework6

    For the basic tutorials, we will use EF 6.0, the latest version of entity framework as of this writing.

    Install the following tools to work with entity framework:

    • .NET Framework 4.5
    • Visual Studio 2012
    • MS SQL Server 2005/2008/2012 Express

    Install EF via Nuget:

    You can install entity framework into your project via nuget. Here, we will install EF (EntityFramework.dll) via nuget in the console application in VS 2012. You can install EF via NuGet the same way in any version of Visual Studio.

    Right click on project in the solution explorer and select Manage NuGet Packages..

    Entity Framework install

    This will open Manage NuGet packages dialogue box. Now, select Online in left bar and search for EntityFramework as shown below.

    Entity Framework install

    This will search for all the packages related to Entity Framework. Select EntityFramework and click on Install.

    Entity Framework install

    Click on the I Accept button in License Acceptance dialogue box. This will start the installation.

    Entity Framework install

    After installation, make sure that the appropriate version of EntityFramework.dll is included in the project.

    Entity Framework install

    Now, you are ready to use Entity Framework in your project.

    Setting up the database:

    This tutorial will use sample SchoolDB which has different tables, stored procedures and views. The SchoolDB database design is shown below:

    Tutorial Sample database design

    You can see in the above diagram that the sample SchoolDB database includes tables with the following relationships, for demo purpose.

    • One-to-One: Student and StudentAddress have a one-to-one relationship eg. Student has zero or one StudentAddress.
    • One-to-Many: Standard and Teacher have a one-to-many relationship eg. many Teachers can be associate with one Standard.
    • Many-to-Many: Student and Course have a many-to-many relationship using StudentCourse table where StudentCourse table includes StudentId and CourseId. So one student can join many courses and one course also can have many students.

    Download Sample Project for all the tutorials on entity framework.

    Let's create first simple Entity Data Model for sample School database in the next section.

  • 相关阅读:
    成为专业程序员路上用到的各种优秀资料、神器及框架
    深度学习的57个专业术语
    Tensorflow实现Mask R-CNN实例分割通用框架,检测,分割和特征点定位一次搞定(多图)
    Python抓取视频内容
    Dataflow编程模型和spark streaming结合
    开启mysql的远程访问
    OpenSSL拒绝服务漏洞(CNVD-2016-01479)
    多款Apple产品libxml2内存破坏漏洞
    Mozilla Network Security Services拒绝服务漏洞
    Linux kernel 'mq_notify'内存错误引用漏洞
  • 原文地址:https://www.cnblogs.com/purplefox2008/p/5648769.html
Copyright © 2020-2023  润新知