每种模板类型的预期用途、优缺点是什么?

发布于 2024-09-29 00:21:06 字数 333 浏览 2 评论 0原文

我几乎没有接触过 EF4,但我经常使用 Linq to sql。我想开始使用其中一个 EF 模板,但我不知道什么情况对每个模板有意义,也不知道它们的意图是什么。

我有以下可能性:

  • 数据模板
    • ADO.NET 实体数据模型
    • 基于服务的数据库(这与 EF 相关吗?
  • 代码模板(我熟悉T4)
    • ADO.NET 实体对象生成器
    • ADO.NET 自跟踪实体生成器
  • 在线模板
    • ADO.NET C# POCO 实体生成器

I have not hardly touched EF4, but I've used Linq to sql quite a lot. I would like to start into one of the EF templates but I have no idea what situations make sense for each or what their intent was.

I have the following possibilities:

  • Data templates
    • ADO.NET Entity Data Model
    • Service-based Database (is this even related to EF?
  • Code templates (I am familiar with T4)
    • ADO.NET EntityObject Generator
    • ADO.NET Self-Tracking Entity Generator
  • Online Templates
    • ADO.NET C# POCO Entity Generator

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最笨的告白 2024-10-06 00:21:06

我不知道情况会怎样
对每个人的意义或他们的意图

有意听起来粗鲁,但您是否查看过 MSDN/ASP.NET 来找出答案?周围有很多信息。每个模板都有很多内容,我无法在此一一介绍。其中每一个都有一个 MSDN 页面。

话虽这么说,我会给您一个快速摘要,以便那些偶然发现这里的人可以获得一些信息。

ADO.NET 实体数据模型

这是您为使用实体框架作为 ORM 而创建的文件,并且对于使用 EF 是必需的。在使用其他任何一个之前,您需要这个。您可以使用多种不同的方法创建 EDM,包括数据库优先(从 DB 生成)、代码优先、模型优先等。

基于服务的数据库

我从未听说过这个术语,并且考虑到我最近经常使用 EF(并阅读),我怀疑这与 EF 相关。

ADO.NET 实体对象生成器

为从 EntityObject 类继承的实体生成类。与默认的 EF 代码生成器相同,只不过不是将输出代码放入 Model.edmx.designer.cs(默认)文件中,而是将代码放入单独的文件中。我个人认为这个模板没有任何好处。

ADO.NET 自跟踪实体生成器

当您想要开发 N 层应用程序(即,如果您想要允许 WCF/Silverlight 应用程序与您的模型一起使用)时,为实体生成类。实体被设置为可由 EF Graph“跟踪”,以便处理来自各种应用程序的持久性操作。

ADO.NET C# POCO 实体生成器

我的最爱。 :) 为从继承的实体生成类。他们不知道自己被用来坚持。当您需要域/持久层的持久性忽略、可测试性和松散耦合时,请将此用于应用程序。

I have no idea what situations make
sense for each or what their intent
was

Not meaning to sound rude, but did you have a look on MSDN/ASP.NET to find out? There is plenty of information around. And there is a lot to each of those templates, more than i can go into here. There is a MSDN page for each of these.

That being said, i'll give you a quick summary, so people who stumble here have some info.

ADO.NET Entity Data Model

This is the file you create to use Entity Framework as your ORM, and it is mandatory for using EF. You need this before you use any of the others. You can create your EDM with a number of different approaches, including database-first (generate from DB), code-first, model-first, etc.

Service-based Database

I have never heard of this term, and given i've been working with EF a lot lately (and reading), i doubt this will be related to EF.

ADO.NET EntityObject Generator

Generates classes for entities which inherit from the EntityObject class. Identical to the default EF code generator, except instead of putting output code into the Model.edmx.designer.cs (default) file, the code gets put into seperate files. I personally don't see any benefit in this template.

ADO.NET Self-Tracking Entity Generator

Generates classes for entities when you want to develop N-Tier applications (ie if you wanted to allow a WCF/Silverlight app to work with your model). Entities are setup to be 'trackable' by the EF Graph, in order to handle persistence operations from various applications.

ADO.NET C# POCO Entity Generator

My favourite. :) Generates classes for entities which inherit from nothing. They have no idea that they are being used for persistence. Use this for applications when you want persistence-ignorance, testability and loose-coupling of your domain/persistence layers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文