为什么POCO类生成EF 4.x版的DbContext发生器C#是局部的? [英] Why POCO Classes generated EF 4.x DbContext Generator for C# are Partial?

查看:124
本文介绍了为什么POCO类生成EF 4.x版的DbContext发生器C#是局部的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用EF 4.3.1和 EF 4.x版的DbContext发生器C#使用T4 创建 POCO。

I'm using EF 4.3.1 and "EF 4.x DbContext Generator for C#" for creating POCO using T4.

生成的类是:

namespace MyProjects.Models
{
    public partial class ReCategory
...

为什么类是局部?

Why the class is PARTIAL?

POCO并非没有EF的管道类?

POCO are not classes without the plumbing of EF?

如果您认为这个问题是不恰当的请评论,我会删除它,感谢您的时间。

If you think this question is not appropriate please comment I will remove it, thanks for your time.

推荐答案

为什么的不应该的他们呢?几乎每一个code发电机,这些天将产生部分类,让您可以在自己的成员添加到类 - 在一个单独的文件

Why shouldn't they be? Just about every code generator these days will generate partial classes, so that you can add your own members to the class - in a separate file.

如果这些类已经得到再生,他们在该文件将被完全取代 - 但您的自定义将生存

If these classes have to be regenerated, the file they are in will be completely replaced - but your customizations will survive.

部分类定义的:

有几种情况时分割一个类定义是可取的:

There are several situations when splitting a class definition is desirable:


      
  • 当使用自动生成的源工作,code可以被添加到类而无需重新创建源文件。创建Windows窗体,Web服务包装code时,等Visual Studio中使用了这种方法。您可以创建code,使用这些类,而无需编辑由Visual Studio创建的文件。

  •   

这篇关于为什么POCO类生成EF 4.x版的DbContext发生器C#是局部的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆