JL.
JL.

Reputation: 81292

Is there a way to create a class from a sql table using visual studio 2010?

I would like to create a c# class definition from a SQL table in Visual Studio 2010.

In Server Explorer I have added a data connection and can browse to the table. This shows me the table definition, but I can't find a way to right click and "generate class".

Is this possible? If not any tool that can do this quickly? I just need 1 class generated from 1 table.

Thanks

EDIT I should also mention I plan to populate this strongly typed collection using ADO.

Upvotes: 2

Views: 4223

Answers (1)

Mark W
Mark W

Reputation: 3909

Try creating a LINQ to SQL project, connect to that database then in the LINQtoSQL browser you'll be able to drag tables into the .dbml diagram and LINQtoSQL will generate a class for you that represents the table along with a class that represents each row in the table.

http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx

Upvotes: 1

Related Questions