http://www.entityframeworktutorial.net/EntityFramework5/setup-entityframework-environment.aspx

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.

右键项目,然后选择“管理NuGet程序包”

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

然后选择联机,并搜索EntityFramework

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.

学生和学生地址,是一对一的关系,学生有一个或0个地址

标准和老师,是一对多的关系,一个标准可以针对于多个老师

学生和课程,是多对多的关系,1个学生可以选修多门课程;一门课程,可以有多个学生选修

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.

Setup Entity Framework Environment的更多相关文章

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

  2. 安装Entity Framework【Setup Entity Framework Environment】(EF基础系列篇4)

    Entity Framework 5.0 API是分布在两个地方:NuGet和.NET Framework中,这个.NET framework 4.0/4.5包含EF核心的API,然而通过NuGet包 ...

  3. EF(Entity Framework)系统学习系列

    好久没写博客了,继续开启霸屏模式,好了,废话不多说,这次准备重新系统学一下EF,一个偶然的机会找到了一个学习EF的网站(http://www.entityframeworktutorial.net/) ...

  4. Entity Framework Code-First(3):Setup Environment

    Setup Development Environment for EF Code-First: Let's setup the development environment for Code-Fi ...

  5. ASP.NET: Setup a MVC5 website with MySQL, Entity Framework 6 Code-First and VS2013

    The new features available in EF6 allow any developer to build a simple DB-powered website with very ...

  6. Entity Framework 6, database-first with Oracle

    Entity Framework 6, database-first with Oracle 转载自http://csharp.today/entity-framework-6-database-fi ...

  7. Managing DbContext the right way with Entity Framework 6: an in-depth guide by mehdime

    UPDATE: the source code for DbContextScope is now available on GitHub: DbContextScope on GitHub. A b ...

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

  9. 《Entity Framework 6 Recipes》中文翻译系列 (13) -----第三章 查询之使用Entity SQL

    翻译的初衷以及为什么选择<Entity Framework 6 Recipes>来学习,请看本系列开篇 3-4使用实体SQL查询模型 问题 你想通过执行Entity SQL语句来查询你的实 ...

随机推荐

  1. poj 1386 Play on Words 有向欧拉回路

    题目链接:http://poj.org/problem?id=1386 Some of the secret doors contain a very interesting word puzzle. ...

  2. 【BZOJ】【1011】【HNOI2008】遥远的行星

    神奇的思路题QAQ 玛雅看到这题我就醉了,什么玩意……5%的误差?果断膜拜@ydc神犇的题解: 就是因为不清楚如何应用那个答案误差不超过5%啦. 从没见过这么诡异的题一下就懵了,问到了方法之后都还半信 ...

  3. nsight 使用问题

    slot 0 offset 0 stride DXGI_FORMAT_r32b32g32_FLOAT 这样一个memory 100.0000, 100.0000,10.0000,1.0000 stri ...

  4. Guid和Int还有Double、Date的ToString方法的常见格式

    Guid的常见格式: 1.Guid.NewGuid().ToString("N") 结果为:       38bddf48f43c48588e0d78761eaa1ce6 2.Gu ...

  5. .net深入体验与实战精要--ASP.NET开发大杂烩(转)

    转自:http://www.cnblogs.com/sunhan/p/3371337.html 正巧今天遇到一个获取动态生成table中的一个动态生成的TextBox的值的时候总是findcontro ...

  6. ios 编码转换 保存文件

    - (NSString *)SaveFileToDocuments:(NSString *)url { // NSString *url = @"http://172.28.250.70/a ...

  7. ios 聊天demo 和nsoperationdemo

    http://blog.csdn.net/zhibudefeng/article/details/7991649 http://blog.csdn.net/kangx6/article/details ...

  8. iOS7 状态栏 修改为白色字体的步骤

    1在Info.plist中设置UIViewControllerBasedStatusBarAppearance 为NO2 在需要改变状态栏颜色的ViewController中在ViewDidLoad方 ...

  9. 免安装jdk 和 免安装tomcat

    免安装tomcat 运行的时候要执行免安装的 jdk,可以进行如下设置. 在 startup.bat 里加上这么一句, set "JAVA_HOME=C:\jdk1.6.0_43"

  10. Visual Studio 快捷键

    Visual Studio 快捷键 CTRL + DELETE 删除至词尾 CTRL + BACKSPACE 删除至词头Ctrl+Shift+L: 删除当前行 Ctrl+K+Crtr+C: 注释选定内 ...