EntityFramework 学习 一 Multiple Diagrams in Entity Framework 5.0

本文介绍如何在Visual Studio 2012中对实体数据模型进行拆分,包括创建新图表的方法及操作步骤。通过拖拽实体至新图表或从现有图表移动实体来实现拆分,并介绍了包含相关实体的操作方式。

Visual Studio 2012 provides a facility to split the design time visual representation of the Entity Data Model. This means that you can have multiple diagrams for one Entity Data Model.

You can create a new diagram in multiple ways:

  1. Add a new diagram and drag and drop entities from Model Browser
  2. Move entities from an existing diagram to a new diagram

1. Add a new diagram and drag and drop entities from Model Browser:

You can add a new diagram by right clicking on the Diagrams node of the model browser and selecting 'Add New Diagram':

Entity Framework 5.0 Tutorial

You can rename the diagram, for example: StudentDiagram to include all student related entities:

Entity Framework 5.0 Tutorial

Now, you can drag and drop Student and StudentAddress entities to this new diagram:

Entity Framework 5.0 Tutorial

2. Move entities from existing diagram to new diagram:

You can also move entities from an existing diagram to a new diagram. For example, if you want to move Teacher and Course entities to a new diagram, then select those entities in an existing diagram and right click and select 'Move to New Diagram' from the context menu:

Entity Framework 5.0 Tutorial

It will create a new diagram and move Teacher and Course entities to a new diagram as shown below:

Entity Framework 5.0 Tutorial

So, in this way you can create a new diagram from an existing diagram.

You can also include the related entities of a particular entity. For example, right click on Student entity → select 'Include Related'. Standard and Course entities will also be included, because Student has their reference property:

Entity Framework 5.0 Tutorial

This will include Standard and Course entity as shown below.

Entity Framework 5.0 Tutorial

Additionally, you can also move properties up or down by right clicking on the property → select Move Property → select UP/Down etc. as shown below:

Entity Framework 5.0 Tutorial

Difference between delete and remove entity:

You can remove the entity from the diagram by right clicking on entity and selecting 'Remove from diagram'.

Entity Framework 5.0 Tutorial

Remove from Diagram will only remove the entity from the diagram whereas 'Delete from Model' will delete the entity from the EDM. So you won't be able to use that entity at all.

 

转载于:https://www.cnblogs.com/lanpingwang/p/6623168.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值