实体框架4 - POCO - T4模板

时间:2010-11-10 00:13:27

标签: templates c#-4.0 entity-framework-4 t4

我在项目中使用EF 4和POCO。目前,我使用这种格式/布局手动创建我需要的POCO:

public class Blog
{
    public int Id { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }

    public virtual IList<BlogPost> BlogPosts { get; private set; }
}

public class BlogPost
{
    public int Id { get; set; }
    public string Title { get; set; }
    public string Content { get; set; }
    public DateTime? PublishedOn { get; set; }

    public virtual Blog Blog { get; set; }
}

这些POCO基于数据库中的表格(博客和BlogPosts)。

您是否可以下载任何T4模板,以使用上面的格式/布局自动创建POCO对象?或者我是否必须创建自己的T4模板?

1 个答案:

答案 0 :(得分:2)

是的,ADO.NET POCO Entity Generator

唯一的事情是在.tt文件中创建POCO,所以如果你想在自己的类中使用它们,你必须手动将它们拉过来。

虽然没什么大不了的,只是让你知道。

相关问题