Setup Entity Framework Environment

时间:2021-09-02 02:50:03

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.

Setup Entity Framework Environment

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

Setup Entity Framework Environment

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

Setup Entity Framework Environment

然后选择联机,并搜索EntityFramework

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

Setup Entity Framework Environment

最后安装

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.

Setup Entity Framework Environment

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

Setup Entity Framework Environment

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:

Setup Entity Framework Environment

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. SharedPreferences 的另一种场景的用法

    SharedPreferences 的另一种场景的用法 昨天,下班在家想做什么来着,然后想用SharedPreferences存点数据,但是不知道咋地突然想到,SharedPreferences是应用 ...

  2. 查看Android应用的package name和activity name方面

    使用android自动化测试工具monkeyrunner启动应用时,需要填写被测程序的包名和启动的Activity,以下有两种查看应用包名package和入口activity名称的方法:方法一:使用a ...

  3. Bootstrap文件上传插件File Input的使用

    基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用 Bootstrap文件上传插件File Input是一个不错的文件上传控件, ...

  4. 使用 GIT 获得Linux Kernel的代码并查看,追踪历史记录

    Linux kernel  的官方 GIT地址是: http://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git 可以从这个地 ...

  5. Pyhton编程(五)之基本数据类型-列表、元组、字典

    一:列表(list) 列表是由一系列按特定顺序排列的元素组成,可以创建包含字母表中的所有字母.数字.或中文的列表,也可以将任何东西加入列表中,其中的元素之间可以没有任何关系. 在Python中,用方括 ...

  6. 《C程序猿从校园到职场》勘误

    (本人正在參加2015博客之星评选.诚邀你来投票,谢谢:username=zhouzxi">http://vote.blog.csdn.net/blogstar2015/candida ...

  7. design principle:java 回调与委派&sol;委托机制

    博客 design principle:模拟 android Button 控件点击事件 主要说了一下模拟 android 的 Listener 模式,其实这就是一种委派与回调机制的体现. 委派,也可 ...

  8. linux 常用命令及实例

    转载:https://www.cnblogs.com/xiaoyafei/p/9163976.html 在linux中,绝大多数命令都参照 命令 选项 参数 选项:适用于调整命令的功能的 参数:指的是 ...

  9. Debian 9 Stretch国内常用镜像源

     随着Debian 9的普及,但由于伟大的墙的存在,那就有必要整理一下国内的镜像站点. 1.使用说明 一般情况下,修改/etc/apt/sources.list文件,将Debian的默认源地址改成新的 ...

  10. Windows下Mongodb启动问题

    把mongodb安装完,运行server出现问题