Generally EF does not support DataSets. If you want to populate DataSets with data loaded with EF then you've got to provide your own functionality for that. Here I present an example how to populate DataTable object from result obtained with query:
public static class IEnumerableExtensions
{
public static DataTable ToDataTable<TEntity>(this IEnumerable<TEntity> entities)
{
DataTable table = new DataTable();
IEnumerable<PropertyInfo> properties = typeof(TEntity)
.GetProperties()
.Where(p => !p.PropertyType.IsClass || p.PropertyType == typeof(string))
foreach(string propertyName in properties.Select( p => p.Name))
{
table.Columns.Add(propertyName);
}
foreach(object item in entities)
{
List<object> propertiesValues = new List<object>();
foreach (PropertyInfo property in properties)
{
propertiesValues.Add(property.GetValue(item));
}
table.Rows.Add(propertiesValues.ToArray());
}
return table;
}
}
You might use then this extension method as follows:
DataTable table = context.People.ToDataTable();
If you want to implement relationships between tables then the logic you have to do will be more complicated. You should use ChildRelations property of DataTable objects to bind them with relations. Then your DataTable objects you might insert into DataSet.