Hey all, I finally got fed up with the ridiculously slow insert times of EntityFramework. So, I went with the SqlBulkCopy route, but that required a second connection to the database, and second connection string in the config file, you're not storing them in the code right...? Well, I created some extension methods to handle this all for me, this takes care of getting the SqlConnection out of the Entity Context. Below is the code to do it.

public static class ObjectContextExtensions
{
    /// <summary>Gets the entity connection object from the object context
    /// </summary>
    /// <param name="context"></param>
    /// <returns></returns>
    public static EntityConnection EntityConnection(this ObjectContext context)
    {
        return context.Connection as EntityConnection;
    }
    
    /// <summary>Gets a sql connection object from an entity connection object
    /// </summary>
    /// <param name="connection"></param>
    /// <returns></returns>
    public static SqlConnection SqlConnection(this EntityConnection connection)
    {
        return connection.StoreConnection as SqlConnection;
    }
    
    /// <summary>Executes a sql bulk copy on an object context with the specified values. Opens the connection if it is not already open.
    /// </summary>
    /// <param name="context">ObjectContext containing the entity framework connection.</param>
    /// <param name="columnMappings">Dictionary of string, string of column mappings,key is the source column, value is the destination column in the table.</param>
    /// <param name="table">Datatable containing the rows to insert into the database.</param>
    /// <param name="destinationTableName">Name of the table in the database.</param>
    /// <param name="batchSize">Amount of rows to insert at a single time, 10000 is a good number for performance but can be fine tuned.</param>
    public static void SqlBulkCopy(this ObjectContext context, Dictionary<string, string> columnMappings, DataTable table, string destinationTableName, int batchSize = 10000)
    {
        EntityConnection entityConnection = context.EntityConnection();

        if (entityConnection == null)
        {
            throw new NullReferenceException("EntityConnection is null or not an EntityConnection.");
        }

        if (entityConnection.State == ConnectionState.Closed)
        {
            entityConnection.Open();
        }

        SqlConnection connection = entityConnection.SqlConnection();

        if (connection == null)
        {
            throw new NullReferenceException("SqlConnection is null or not a SqlConnection.");
        }

        using (SqlBulkCopy bulk = new SqlBulkCopy(connection))
        {
            foreach (KeyValuePair<string, string> kvp in columnMappings)
            {
                bulk.ColumnMappings.Add(kvp.Key, kvp.Value);
            }

            bulk.DestinationTableName = destinationTableName;
            bulk.BatchSize = batchSize;

            bulk.WriteToServer(table);
        }
    }
}