The Configuration Class2:09 with James Churchill
Let's take a look at the Configuration class that was added to our project when we enabled migrations.
To follow along commiting your changes to this course, you'll need to fork the dotnet-ef-migrations repo. Then you can clone, commit, and push your changes to your fork like this:
git clone <your-fork> cd dotnet-ef-migrations git checkout tags/v1.3 -b the-configuration-class
Lets take a look at the configuration class that was added to our project 0:00 when we enabled migrations. 0:03 The configuration class allows us to configure how migrations behaves for 0:08 our context. 0:13 We can also use the Seed method to seed our database with data 0:14 which is what we'll do later in this section. 0:18 The only configuration option that we're using 0:21 is the automatic by Gratian's enabled property 0:24 which we're setting ti false in order to disable automatic migrations. 0:27 Automatic migrations allows you to use migrations without having to add a code 0:31 file to your project for each set of changes that you make to your model. 0:36 On the surface, this sounds great. 0:40 But you lose the explicitness of being able to see your migrations expressed over 0:43 time in code, which is one of the benefits of using code first migrations. 0:47 We're not going to cover automatic migrations in this course. 0:53 If you'd like to learn more about automatic migrations, 0:56 see the teacher's notes. 0:59 We can see the other available configuration properties 1:01 by navigating to the definition of the DbMigrationsConfiguration base class. 1:04 I'll put my cursor on the DbMigrationsConfiguration 1:09 generic base class and press F12. 1:12 Then, I'll put my cursor on the DbMigrationsConfiguration, 1:16 non-generic base class, and press F12 again. 1:19 The CommandTimeout property can be helpful when you have a migration that takes 1:30 longer than the default command timeout for 1:34 the data provider that EF is configured to use. 1:37 If you're using the data provider for Sequel Server, the default is 30 seconds. 1:40 The vast majority of the time, 30 seconds is more than sufficient for 1:44 a database operation to complete. 1:49 But when a migration needs to work with large amounts of data, 1:52 you might need to increase the time out. 1:55 For more information about these other configuration properties, 2:00 see the teacher's notes. 2:03 Next we'll see how to add our first migration. 2:05
You need to sign up for Treehouse in order to download course files.Sign up