Insight.Database.Schema is a dead-simple easy to use SQL Server database script installer and "SQL code migrator".
Huzzah! v2.0 is finally done!
Why is 2.0 better?
Also...
See the wiki!
You can read these to get a flavor for the beer/code. But you should go over to the wiki.
So assume you have Beer.sql:
CREATE TABLE Beer
(
[ID] [int] IDENTITY,
[Name] [varchar](128)
)
GO
CREATE PROC InsertBeer (@Name [varchar](128)) AS
INSERT INTO Beer (Name)
OUTPUT Inserted.ID VALUES (@Name)
GO
Only a little code is needed to deploy your SQL.
// load your SQL into a SchemaObjectCOllection
SchemaObjectCollection schema = new SchemaObjectCollection();
schema.Load("Beer.sql");
// automatically create the database
SchemaInstaller.CreateDatabase(connectionString);
// automatically install it, or upgrade it
using (SqlConnection connection = new SqlConnection (connectionString))
{
connection.Open();
SchemaInstaller installer = new SchemaInstaller(connection);
new SchemaEventConsoleLogger().Attach(installer);
installer.Install("BeerGarten", schema);
}
Go ahead. Just modify the SQL. Don't worry about writing upgrade scripts.
CREATE TABLE Beer
(
[ID] [int] IDENTITY NOT NULL,
[Name] [varchar](128) NOT NULL,
[Description] [varchar](MAX)
)
GO
CREATE PROC InsertBeer (@Name [varchar](128), @Description [varchar](MAX)) AS
INSERT INTO Beer (Name, Description)
OUTPUT Inserted.ID VALUES (@Name, @Description)
GO
Now, run your setup program again. Insight will automatically calculate the differences between the existing database and your new database. Then it will only make the changes necessary to update your database.
Automatically generate standard stored procedures for your tables and have them updated automatically if you change your schema.
Get all of these for FREE! Select, Insert, Update, Upsert, Delete, SelectMany, InsertMany, UpdateMany, UpsertMany, DeleteMany, Find.
-- automatically generates Select/Insert/Update/Delete/Find and more
-- AUTOPROC All [Beer]
GO
You don't have to use Insight.Database if you don't want to, but it's easy and fast.
To call your stored procedures (and SQL) easily. Use Insight.Database! It can even automatically generate a repository for all of the AutoProcs. You can select objects and send them back to the database with almost no effort!