Skip to content
schambers edited this page Sep 14, 2010 · 27 revisions

The FM fluent api allows you to create tables, columns, indexes and (nearly) every construct you need to manipulate your database structure.

Behind the scenes, the fluent api populates a semantic model that FM uses to analyze and apply migrations in batch. The fluent api that is available in your Migration class starts with five main root expressions as follows:

Create Expression

Allows you to create a table, column, index, foreign key and schema.

Create.Table("Users")
    .WithIdColumn()
    .WithColumn("Name").AsString().NotNullable();

Delete Expression

Allows you to delete a table, column, foreign key and schema.

Delete.Table("Users");

Execute Expression

Allows you to execute a block of sql, or a script by name (ie. myscript.sql)

Execute.Script("myscript.sql");

Execute.Sql("DELETE TABLE Users");

Insert Expression

Allows you to insert a row into a table using an anonymous type for the rows contents

Insert.IntoTable("Users").Row(new { FirstName = "John", LastName = "Smith" });

Rename Expression

Allows you to rename a column or table.

Rename.Table("Users").To("UsersNew");

Next up, Profiles are migrations that if specified, will always run regardless of what other migrations run.

Clone this wiki locally