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.

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

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..

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

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

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

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

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:

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.

Entity Framework Tutorial Basics(4):Setup Entity Framework Environment的更多相关文章

  1. Entity Framework Tutorial Basics(27):Update Entity Graph

    Update Entity Graph using DbContext: Updating an entity graph in disconnected scenario is a complex ...

  2. Entity Framework Tutorial Basics(26):Add Entity Graph

    Add Entity Graph using DbContext: Adding entity graph with all new entities is a simple task. We can ...

  3. Entity Framework Tutorial Basics(42):Colored Entity

    Colored Entity in Entity Framework 5.0 You can change the color of an entity in the designer so that ...

  4. Entity Framework Tutorial Basics(5):Create Entity Data Model

    Create Entity Data Model: Here, we are going to create an Entity Data Model (EDM) for SchoolDB datab ...

  5. Entity Framework Tutorial Basics(40):Validate Entity

    Validate Entity You can write custom server side validation for any entity. To accomplish this, over ...

  6. Entity Framework Tutorial Basics(1):Introduction

    以下系列文章为Entity Framework Turial Basics系列 http://www.entityframeworktutorial.net/EntityFramework5/enti ...

  7. Entity Framework Tutorial Basics(32):Enum Support

    Enum in Entity Framework: You can now have an Enum in Entity Framework 5.0 onwards. EF 5 should targ ...

  8. Entity Framework Tutorial Basics(31):Migration from EF 4.X

    Migration from Entity Framework 4.1/4.3 to Entity Framework 5.0/6.0 To migrate your existing Entity ...

  9. Entity Framework Tutorial Basics(22):Disconnected Entities

    Disconnected Entities: Before we see how to perform CRUD operation on disconnected entity graph, let ...

随机推荐

  1. 242. Valid Anagram Add to List

    Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = &q ...

  2. [SP16549]QTREE6

    luogu vjudge 题意 给你一棵n个点的树,编号1~n.每个点可以是黑色,可以是白色.初始时所有点都是黑色.支持两种操作: 0 u:询问有多少个节点v满足路径u到v上所有节点(包括)都拥有相同 ...

  3. 2017.10.7北京清北综合强化班DAY7

    1.计数 (count.cpp/c/pas) 时间限制:1s 内存限制:256MB [问题描述] 给出m个数a[1],a[2],…,a[m] 求1~n中有多少数不是a[1],a[2],…,a[m]的倍 ...

  4. webpack入门(四)——webpack loader 和plugin

    什么是loader loaders是你用在app源码上的转换元件.他们是用node.js运行的,把源文件作为参数,返回新的资源的函数. 例如,你可以用loaders告诉webpack加载 coffee ...

  5. ubuntu更改用户登录密码

    sudo passwd user(root或对应的用户名)

  6. mysql之 共享表空间与独立表空间、frm,MYD,MYI.idb,par文件说明

    一.共享表空间与独立表空间MySQL5.5默认是共享表空间 ,5.6中,默认是独立表空间. 共享表空间:ibdata1是InnoDB的共享表空间,默认配置是把全部表空间存放到ibdata1中,因此而造 ...

  7. 【Linux网络编程】基于TCP流 I/O多路转接(poll) 的高性能http服务器

    服务器比较简陋,为了学习poll的使用,只向客户端回写一条html语句.启动服务器后,浏览器发起请求,服务端向浏览器写回html,响应字符串,然后可以看到,浏览器解析并显示 Hello Poll!. ...

  8. 对于org.apache.commons.dbcp.BasicDataSource的配置认知

    对于org.apache.commons.dbcp.BasicDataSource的配置认知[转] Spring在第三方依赖包中包含了两个数据源的实现类包,其一是Apache的DBCP,其二是 C3P ...

  9. Linux python安装

    Linux 安装 Python3.5   1. 准备 操作系统:Red Hat Enterprise Linux Server release 6.5 (Santiago) Python 安装包:Py ...

  10. Excel开发学习笔记:VB.net的一些杂项

    遇到一个数据处理自动化的问题,于是打算开发一个基于excel的小工具.在业余时间一边自学一边实践,抽空把一些知识写下来以备今后参考,因为走的是盲人摸象的野路子,幼稚与错误请多包涵. 开发环境基于VST ...