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. uva1152 - 4 Values whose Sum is 0(枚举,中途相遇法)

    用中途相遇法的思想来解题.分别枚举两边,和直接暴力枚举四个数组比可以降低时间复杂度. 这里用到一个很实用的技巧: 求长度为n的有序数组a中的数k的个数num? num=upper_bound(a,a+ ...

  2. python 调试命令

    部分整理自:http://flysnowxf.iteye.com/blog/1327677 启动调试: python -m pdb xxx.py 常用命令说明: l #查看运行到哪行代码 n #单步运 ...

  3. 洛谷 P1655 小朋友的球

    题目描述 @发源于 小朋友最近特别喜欢球.有一天他脑子抽了,从口袋里拿出了N个不同的球,想把它们放到M个相同的盒子里,并且要求每个盒子中至少要有一个球,他好奇有几种放法,于是尝试编程实现,但由于他天天 ...

  4. 学习动态性能表(9)--v$filestat

    学习动态性能表 第九篇--V$FILESTAT  2007.6.5 本视图记录各文件物理I/O信息.如果瓶颈与I/O相关,可用于分析发生的活动I/O事件.V$FILESTAT显示出数据库I/O的下列信 ...

  5. mysql5.6之 传输表空间迁移表或恢复误删除的表

    一,简单说明: 1),传输表空间的限制:  1,mysql 版本 5.6.6 及其以上,并且版本建议源和目标版本建议都是GA版并且大版本一样  2,表引擎为innodb并且开启独立表空间  innod ...

  6. 13.Selenium不再支持PhantomJS

    在网上查看Selenium教程,发现很多都是使用PhantomJS进行爬虫,故想学习下,下载好了PhantomJS,配好了环境变量,编写代码后发现以下错误 from selenium import w ...

  7. 基于springboot+kotlin+gradle构建的框架的坑

    项目采用以上技术构建,于是本人就尝试构建自己的脚手架,然后遇到一大推问题. 使用的是springinitials构建,IDE是:IDEA 现在也是知其然不知其所以然,但是先记录下来修改过程,以后等知识 ...

  8. java中io的详解

    注:本文全篇转载于:http://blog.csdn.net/taxueyingmei/article/details/7697042,觉得讲的挺详细,就借过来看看,挺不错的文章. 先贴一张图 Jav ...

  9. linux下的时间

    1.linux下时间管理机制: 在系统启动时,Linux操作系统将时间从CMOS中读到系统时间变量中,以后修改时间通过修改系统时间实现.为了保持系统时间与CMOS时间的一致性,Linux每隔11分钟会 ...

  10. POJ3292(素数筛选)

    Semi-prime H-numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8706   Accepted: 3 ...