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.

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的更多相关文章
- Entity Framework Tutorial Basics(27):Update Entity Graph
Update Entity Graph using DbContext: Updating an entity graph in disconnected scenario is a complex ...
- 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 ...
- 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 ...
- 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 ...
- Entity Framework Tutorial Basics(40):Validate Entity
Validate Entity You can write custom server side validation for any entity. To accomplish this, over ...
- Entity Framework Tutorial Basics(1):Introduction
以下系列文章为Entity Framework Turial Basics系列 http://www.entityframeworktutorial.net/EntityFramework5/enti ...
- 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 ...
- 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 ...
- Entity Framework Tutorial Basics(22):Disconnected Entities
Disconnected Entities: Before we see how to perform CRUD operation on disconnected entity graph, let ...
随机推荐
- andriod&linux&c函数原型
1.dlopen 功能:打开一个动态链接库,并返回动态链接库的句柄 包含头文件: #include <dlfcn.h> 函数定义: void * dlopen( const char * ...
- ThreadPoolTaskExecutor异常收集
ThreadPoolTaskExecutor ipFinderThreads = new ThreadPoolTaskExecutor(); ipFinderThreads.setCorePoolSi ...
- DBUtils使用BeanListHandler及BeanHandler时返回null
一.使用Bean相关方法时返回null 问题描述: 使用DBUtils查询数据,如果使用ArrayListHandler等都能够返回正确值,但使用BeanListHandler 和 BeanHandl ...
- Celery-4.1 用户指南: Task(任务)
任务是构建 celery 应用的基础块. 任务是可以在任何除可调用对象外的地方创建的一个类.它扮演着双重角色,它定义了一个任务被调用时会发生什么(发送一个消息),以及一个工作单元获取到消息之后将会做什 ...
- 2015.12.12 DataGridveiw中添加checkbox列
最简单的办法是通过DataTable来添加 DataTable中添加bool类型的列 dtpdf.Columns.Add("入库", typeof(bool)); DataRow ...
- DAY17-Django之model增删改
添加表记录 普通字段 #方式1 publish_obj=Publish(name="人民出版社",city="北京",email="renMin@16 ...
- [Python Study Notes]饼状图绘制
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ...
- strophe与openfire模拟的XMPP简单hello程序
/* * 参考<XMPP高级编程+使用JavaScript和jQuery>第三章例子. * 我修改了作者的XMPP服务器到本地的openfire.JavaScript跨域请求,使用Ngin ...
- @SuppressWarnings("unused")注解的作用
JDK5.0后的新特性,你在使用IDE如eclipse的时候,当你定义了一个变量如int a=0;但是你后面根本就没有使用到这个变量,这一行的前面会有一个黄色的警告标志,你将鼠标移动到上面会提示“这个 ...
- import random随机生成验证码
#!/usr/bin/env python import random temp = "" for i in range(6): num = random.randrange(0, ...