Some background:
The entity 'Batch' is totally empty, and as such, not a candidate to save. This is done to prevent phantom inserts, e.g. due to databinding entities are added to collections or other references of the entity graph and although they're totally empty, they're still saved.
You want to save the entity even though it's empty. You can, but you have to signal it's not 'empty':
[Test]
public void InsertWithDefaultsTest()
{
using(var adapter = new DataAccessAdapter())
{
var toInsert = new OrderEntity();
try
{
toInsert.Fields.IsDirty = true;
Assert.IsTrue(adapter.SaveEntity(toInsert));
Assert.IsTrue(toInsert.OrderId > 0);
}
finally
{
Assert.IsTrue(adapter.DeleteEntity(toInsert));
}
}
}
Here I mark it as 'dirty'. This will generate:
RT version: 3.5.0.0.08242012
Method Enter: CreateInsertDQ
Method Enter: CreateSingleTargetInsertDQ
Generated Sql query:
Query: INSERT INTO [Northwind].[dbo].[Orders] DEFAULT VALUES ;SELECT @p1=SCOPE_IDENTITY()
Parameter: @p1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Output. Value: <undefined value>.
Method Exit: CreateSingleTargetInsertDQ
Method Exit: CreateInsertDQ
Method Enter: CreateDeleteDQ(4)
Method Enter: CreateSingleTargetDeleteDQ(3)
Method Enter: CreateSingleTargetDeleteDQ(4)
Generated Sql query:
Query: DELETE FROM [Northwind].[dbo].[Orders] WHERE ( [Northwind].[dbo].[Orders].[OrderID] = @p1)
Parameter: @p1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 13216.
Method Exit: CreateSingleTargetDeleteDQ(4)
Method Exit: CreateSingleTargetDeleteDQ(3)
Method Exit: CreateDeleteDQ(4)
1 passed, 0 failed, 0 skipped, took 2,73 seconds (NUnit 2.5.5).
As you can see, it does generate the desired query you want, but it only does that if it's explicitly told to accept the empty entity container as being 'a valid entity' as it isn't a valid entity without the dirty flag being false, as David described above. Once it's been accepted as 'valid' for persistence, it goes into the pipeline and there the persistence info is available which contains the identity info.