views:

143

answers:

3

Does anyone know of a SQL library in ASP.NET that can be used to manage tables?

Eg

SQLTable table = new SQLTable();

table.AddColumn(“First name”, varchar, 100);

table.AddColumn(“Last name”, varchar, 100);

if(table.ColumnExists(“Company”))

table.RemoveColumn(“Company”);

The operations I am looking for are adding, editing and deleting tables, fields, indexes and foreign keys.

This can be done using SQL but it is messy, I am looking for a clean API that is intuitive to use.

+1  A: 

Subsonic has a migrations feature. It's fairly new, but I think it meets your 'intuitive' requirement.

ranomore
Subsonic will also build scaffolds for you. That's another nice thing that I like about it.
hectorsosajr
A: 

I would tell you to use SQL DMO, but it looks like it's being discontinued by the looks of it:

http://msdn.microsoft.com/en-us/library/ms131540.aspx

Not sure what it's being replaced with.

Dan Esparza
+1  A: 

Use Microsoft.SqlServer.Management.Smo

Other option would be to install the Microsoft Sql Server Web Data Administrator

Sql Server Web Data Administrator

Some references for Smo:

Create Table in SQL Server 2005 Using C# and SMO

How to: Create, Alter, and Remove a Table in Visual Basic .NET (sorry for lang choice)

NTulip