I’m looking for a tutorial, guidance or software that can generate simple POCO’s for some SQL Server tables for use in ASP.NET MVC. Something like this:
1) Keep a list of the table names in the SQL Server database that should have a POCO generated
2) Feed the list to some program
3) The program generates a simple POCO (more like DTO) in a single .cs file, or appends to a Poco.cs. Either way, it doesn’t matter.
For example:
public class MyDto
{
public int Id { get; set; }
public string Name { get; set; }
public bool? IsMale {get; set;}
}
4) Run the program whenever I want to re-generate the POCO’s
The program could be WinForm, commandline, or something else. It doesn’t matter.
I have wanted to answer this but been busy.
I have created a simple example on how to read a database schema and generate classes and properties from this.
Basically you should be able to cutnpaste this into a TT file (see Oleg Sychs blog on how to get started), update the connection string and save to execute the template.
I don’t claim that this is a complete sample but it could serve as a starting point for you: