In this recipe, we will learn the new EF 7 long request batch features.
We will use Visual Studio 2015 with EF 7, using the SQL Server provider.
In the previous recipe, we installed xUnit
to run the unit test. In this recipe, we will create another unit test to run batches with EF.
We will see the generated SQL in the SQL profiler, a tool used to capture the database traffic on our SQL server. In this way, we will be able to watch the SQL code generated by EF.
- First, we will configure the
DbContext
to indicate what the maximum number of requests we will allow for thisDbContext
should be, and, optionally, the timeout duration in the new unit test method we've just created:
- Next, let's add some requests to insert some items in the
Book
table:
We can see the generated SQL in the SQL Profiler now:
- Next, let's add some requests to update some items in the
Book
table
We can see the generated SQL in the SQL Profiler:
- Let's see the item in the
Book...