Thanks the buying the book and taking time to post this question.
You can use EntityFramework and Linq2SQL in a code first manner, check out the code from chapter 7, here the entities are POCO and there is a Entity Framework and a NHibernate repository.
Here are some good videos on code first Entity Framework development:
Julie Lerman Domain Driven Entity Framework
Julie Lerman Entity Framework Persistance Ignorance
However you can still use database first and just use something like Linq2SQL as a strongly typed data access layer, a bit like this..
public class CustomerRepository : ICustomerRepository
public Customer FindBy(int id)
// Actual entity built code first
Customer customerEntity = null;
// Object created by Linq2SQL
CustomerData customerDataTable = DataContextFactory
.FirstOrDefault<CustomerData>(c => c.Id == id);
// If there is a matching object
if (customerDataTable != null)
// Create a Customer Entity from it
customerEntity = ConvertIntoACustomerEntity(customerDataTable);
public Customer ConvertIntoACustomerEntity(CustomerData customerDataTable)
return new Customer()
Id = customerDataTable.Id,
Name = new Name(customerDataTable.FirstName, customerDataTable.LastName)
But this way you would have to create extra classes for lazy loading etc.
Unfortunately I haven't used SubSonic or Mindscape LightSpeed, but if it follows the Active Record pattern you should be able to use the same method as with Linq2SQL.
I am a couple of weeks away from adding an Entity Framework repository layer to the Agatha solution, plus replacing the QueryObjects with Linq Expression trees, as well as moving to a Command Query Responsibility Segregation type architecture so hopefully this will help you out.
Let me know if I have missed something or not answered ok.