Adding a Movie Kind Field
To include TV series and mini-series in your movie database, you'll need to add a new field called "MovieKind." Since we didn't include it during the initial table creation, we'll create a new migration to add it to our database.
Note: Do not modify existing migrations, as they will not run again.
Create a new migration file under Migrations/DefaultDB/DefaultDB_20221114_1825_MovieKind.cs:
using FluentMigrator; namespace MovieTutorial.Migrations.DefaultDB; [DefaultDB, MigrationKey(20221114_1825)] public class DefaultDB_20221114_1825_MovieKind : AutoReversingMigration { public override void Up() { Alter.Table("Movie") .AddColumn("Kind").AsInt32().NotNullable().WithDefaultValue(1); } }Declare a
MovieKindenumeration that defines the types of movies. You can create this enumeration in Modules/MovieDB/Movie/MovieKind.cs:namespace MovieTutorial.MovieDB; [EnumKey("MovieDB.MovieKind")] public enum MovieKind { [Description("Film")] Film = 1, [Description("TV Series")] TvSeries = 2, [Description("Mini Series")] MiniSeries = 3 }Add the
Kindfield to theMovieRowentity class. Manually add theKindproperty to yourMovieRow.csafter theRuntimeproperty:[DisplayName("Runtime (mins)")] public int? Runtime { get => fields.Runtime[this]; set => fields.Runtime[this] = value; } [DisplayName("Kind"), NotNull] public MovieKind? Kind { get => fields.Kind[this]; set => fields.Kind[this] = value; }In the
RowFieldsclass within the sameMovieRow.csfile, add theKindfield after theRuntimefield:public class RowFields : RowFieldsBase { // ... public Int32Field Runtime; public EnumField<MovieKind> Kind; }To make the
Kindfield available in the movie form, you need to modify theMovieForm.csfile:// ... public class MovieForm { // ... public int Runtime { get; set; } public MovieKind Kind { get; set; } }To make the
Kindfield available in the movie grid, you need to modify theMovieColumns.csfile:// ... public class MovieColumns { // ... public int Runtime { get; set; } public MovieKind Kind { get; set; } }Rebuild your solution to ensure there are no build errors and run your application. Now, in the "Add Movie" dialog, you'll have a dropdown to select the movie kind.

Since "Kind" is a required field, you need to provide a default value in the "Add Movie" dialog to avoid validation errors. Most movies will likely be feature films, so let's set "Film" as the default value for the "Kind" property. To add a default value for the "Kind" property, modify the
MovieRow.csfile by adding aDefaultValueattribute like this:[DisplayName("Kind"), NotNull, DefaultValue(MovieKind.Film)] public MovieKind? Kind { get => fields.Kind[this]; set => fields.Kind[this] = value; }
Now, when you open the "Add Movie" dialog, the "Kind" field will be pre-filled with "Film".
