[翻译]ADO.NET Entity Framework Beta2(八)/快速入门(实体框架)(3)/生成学校实体数据模型

简介:

In this task, you will learn to use the Entity Data Model Wizard to generate a set of 1:1 entity-to-table mapping files for the School model. The School model is used throughout the Entity Framework getting started documentation.

在本任务中,你将学习使用实体数据模型向导来为学校模型生成实体与表一一对应的映射文件。这个学校模型在 实体框架开始文档中被提出。

To add the ADO.NET Entity Data Model item template/添加ADO.NET 实体数据模型项模板

  1. Select the ClassSchedule project in the Solution Explorer, right-click, point to Add, and then click New Item.
    解决方案资源管理器中选中ClassSchedule项目,右击鼠标,选择添加,再选择新建项

  2. Select ADO.NET Entity Data Model in the Templates pane.
    在模板面板内选择ADO.NET Entity Data Model

  3. Type School.csdl for the model name and click Add.
    给模型命名叫School.csdl,然后点添加(实际情况是我看见的默认文件后缀是.edmx)

    The opening page of the Entity Data Model Wizard is displayed.
    本操作将启动实体数据模型向导。(上面的后缀就用默认的edmx,向导一样出来的)

To generate the EDM Files/生成EDM文件

  1. Select Generate from database in the Choose Model Contents dialog box. Then click Next.
    选择模型内容对话框内选择从数据库生成,然后单击下一步

  2. Click the New Connection button.
    单击新建连接按钮

    The Connection Properties dialog box is displayed.
    连接属性对话框被显示出来。

  3. Enter your server name, select the authentication method, type School for the database name, and then click OK.
    输入你的数据库服务器实例名,选则登陆验证方式,输入已经创建的数据库名School,然后点击确定。

    The Choose Your Data Connections dialog box is updated with your database connection settings.
    根据你选择的数据连接设置,选择数据连接的对话框内容被更新。

  4. Ensure that Save entity connection settings in App.Config as: is checked and the value is set to SchoolModel. Then click Next.
    检查确认将实体连接字符串保存到App.Config复选框已经被打上钩,并且文本框内的值是SchoolModel(实际操作时名称是SchoolEntites).单击下一步。

    The Choose Your Database Objects dialog box is displayed.
    选择你的数据库对象对话框被现实。(这个时候下面的文本框内容倒是SchoolModel)

  5. Ensure that all tables are selected, and then click Finish to complete the wizard.
    确认所有的表都被选中了。然后单击结束按钮以完成整个向导。

    The wizard does the following:
    向导为我们做了下列事情:

    • Adds references to the System.Data and System.Data.Entity namespaces.
      添加了对System.Data和System.Data.Entity命名空间的引用
    • Generates .csdl, .ssdl, and .msl files.
      生成.csdl、.ssdl和.msl文件

    • Creates a source code file that contains the classes that were generated from the .csdl file. You can view the source code file by expanding the .csdl file in the Solution Explorer.
      创建了一个源码文件包含了根据.csdl文件生成的类代码。你可以通过展开解决方案管理器里的.csdl文件来查看这些源文件。

    Note /注意
    In Visual Basic projects, you must press the Show All Files button in the Solution Explorer before you can view the source code. 在VB项目中,你必须使用 显示所有文件 按钮 在解决方案资源管理器 中 才能看到这些源代码。 
    • Creates an App.Config file.
      创建了一个App.Config文件。

Next Steps/下一步

You have successfully generated the mapping files and class definitions for the School model in the ClassSchedule project. Next, you will create queries against CLR objects that represent entities and associations in the School model:

你已经成功的为ClassSchedule项目的学校模型生成了映射文件和有关的类定义。下一步,你将创建基于CLR对象的查询来查询学校模型中的实体和关系。

Querying Entities and Associations/查询实体和关系

See Also/请参考

Concepts/概念

Generating an Entity Data Model/生成实体数据模型
Mapping a Conceptual Model to a Storage Schema/将概念模型映射到存储架构

Other Resources/其他资源

Walkthrough: Using the Entity Data Model Wizard
Feature Reference (Entity Framework)/功能参考(实体框架)

 

作者: 徐少侠
出处: http://www.cnblogs.com/Chinese-xu/

本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
如有问题,可以通过 Chinese_Xu@126.com 联系我,非常感谢。

分享家:Addthis中文版
标签: 入门, .NET, 编程, EF

本文转自徐少侠博客园博客,原文链接:http://www.cnblogs.com/Chinese-xu/archive/2007/09/26/906462.html,如需转载请自行联系原作者
目录
相关文章
|
11天前
|
数据可视化 网络协议 C#
C#/.NET/.NET Core优秀项目和框架2024年3月简报
公众号每月定期推广和分享的C#/.NET/.NET Core优秀项目和框架(每周至少会推荐两个优秀的项目和框架当然节假日除外),公众号推文中有项目和框架的介绍、功能特点、使用方式以及部分功能截图等(打不开或者打开GitHub很慢的同学可以优先查看公众号推文,文末一定会附带项目和框架源码地址)。注意:排名不分先后,都是十分优秀的开源项目和框架,每周定期更新分享(欢迎关注公众号:追逐时光者,第一时间获取每周精选分享资讯🔔)。
|
2月前
|
开发框架 JavaScript 前端开发
5个.NET开源且强大的快速开发框架(帮助你提高生产效率)
5个.NET开源且强大的快速开发框架(帮助你提高生产效率)
|
29天前
|
开发框架 网络协议 .NET
深入.net框架
深入.net框架
11 0
|
2月前
|
算法 BI API
C#/.NET/.NET Core优秀项目和框架2024年1月简报
C#/.NET/.NET Core优秀项目和框架2024年1月简报
|
2月前
|
SQL 开发框架 .NET
ASP.NET WEB+EntityFramework数据持久化——考核练习库——1、用户管理系统(考点:查询列表、增加、删除)
ASP.NET WEB+EntityFramework数据持久化——考核练习库——1、用户管理系统(考点:查询列表、增加、删除)
67 0
|
3月前
|
PHP Windows
php扩展com_dndnet(PHP与.NET框架进行交互)
php扩展com_dndnet(PHP与.NET框架进行交互)
php扩展com_dndnet(PHP与.NET框架进行交互)
|
3月前
|
开发框架 前端开发 JavaScript
一款基于.NET Core的快速开发框架、支持多种前端UI、内置代码生成器
一款基于.NET Core的快速开发框架、支持多种前端UI、内置代码生成器
|
3月前
|
开发框架 前端开发 .NET
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
38 0
|
30天前
|
开发框架 前端开发 .NET
进入ASP .net mvc的世界
进入ASP .net mvc的世界
28 0
|
30天前
mvc.net分页查询案例——mvc-paper.css
mvc.net分页查询案例——mvc-paper.css
5 0