thd
thd

Reputation: 2083

Entity Framework 4 - POCO - T4 Template

I am using EF 4 and POCOs in a project. Currently, I manually create POCOs that I need using this format/layout:

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

These POCOs are based on my tables (Blogs and BlogPosts) in the database.

Are there any T4 templates that you can download to have your POCO objects created automatically using the format/layout above? Or do I have to create my own T4 templates?

Upvotes: 0

Views: 2074

Answers (1)

RPM1984
RPM1984

Reputation: 73102

Yes there is, the ADO.NET POCO Entity Generator.

The only thing is is creates the POCO's in a .tt file, so if you want them in your own classes you'll have to manually pull them over.

Not a big deal though, just letting you know.

Upvotes: 2

Related Questions