2010-11-10 249 views
0

我在项目中使用EF 4和POCO。目前,我手动创建波苏斯,我需要使用此格式/布局:实体框架4 - POCO - T4模板

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; } 
} 

这些波苏斯是基于我的数据库中的表(博客和相关博客文章)。

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

+0

您是否看到我的下方答案? – RPM1984 2010-11-10 23:32:03

回答

2

是的,有ADO.NET POCO Entity Generator

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

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

+0

谢谢。我还发现这个视频非常有用:http://msdn.microsoft.com/en-us/data/ff717739.aspx – thd 2010-11-14 15:15:41

+0

太好了,很高兴提供帮助。 – RPM1984 2010-11-14 21:09:14