Generate C# source code for model classes from database table schema for .Net 3.5 application

3.8k Views Asked by At

I create some WinForms apps using Ado.Net to connect the database. I'm using MVP model.

The application uses .Net 3.5 so I cannot use EF 5.0 and I am not willing to use lower version of EF. I'm using VS 2012 though. Is there any tool can be used to generate the C# model classes from the database table schema?

2

There are 2 best solutions below

7
On

This is called Entity Framework Model First: you generate Edmx designer-based model basing on existing database schema, and then POCO-classes basing on this model.

Visual Studio 2012 supports the approach by default: Add -> New item -> Data -> EF 5.x DbContext Generator.

0
On

There is a windows tool available SqlToCSharp which creates C# classes for Database tables, Views, SPs etc.

I have developed it, I am sure it will be helpful to solve the mentioned issue.