POCOs can be mapped so it can be used with a DataContext.
However, I find the mapping a bit leaky. Data model information is now leaking to the domain entity. Consider this example:
<Table Name="dbo.products">
<Type Name="Ptc.Store.Core.Product">
<Column Name="id" Member="Id" IsDbGenerated="true" IsPrimaryKey="true" CanBeNull="false" DbType="INT NOT NULL IDENTITY" />
<Column Name="name" Member="Name" CanBeNull="false" DbType="VARCHAR(50) NOT NULL" />
</Type>
</Table>
<Table Name="[dbo].branches">
<Type Name="Ptc.Store.Core.Branch">
<Column Name="id" Member="Id" IsDbGenerated="true" IsPrimaryKey="true" DbType="INT NOT NULL IDENTITY" />
<Column Name="name" Member="Name" CanBeNull="false" DbType="VARCHAR(50) NOT NULL" />
</Type>
</Table>
<Table Name="[dbo].sales">
<Type Name="Ptc.Store.Core.Sale">
<Column Name="id" Member="Id" IsDbGenerated="true" IsPrimaryKey="true" CanBeNull="false" DbType="INT NOT NULL IDENTITY" />
<Column Name="transaction_date" Member="TransactionDate" CanBeNull="false" DbType="DATETIME" />
<Column Name="amount" Member="Amount" CanBeNull="false" DbType="MONEY" />
<Association Name="sales_item" Member="Item" IsForeignKey="true" ThisKey="ProductId" OtherKey="Id" />
<Association Name="sales_location" Member="Location" IsForeignKey="true" ThisKey="BranchId" OtherKey="Id" />
<!-- Why do I have to map foreign keys? Looks leaky to me.-->
<Column Name="product_id" Member="ProductId" CanBeNull="false" DbType="INT" />
<Column Name="branch_id" Member="BranchId" CanBeNull="false" DbType="INT" />
</Type>
</Table>
The worse part is that I have to explicitly declare properties on my entities to match the data model's foreign keys. I didn't have to do this with NHibernate.
Is there any better way to do this without explicitly writing properties and their mapping to the data model?