Repository: microsoft/Qcodes

Issue:
Bug: experiment id not properly attributed when calling the load_experiment_by_name method
Steps to reproduce: 

```python
from qcodes.dataset.measurements import Measurement

# Start with a clean data base
db_location = qcodes.config["core"]["db_location"]
db = DataSet(db_location)
exp = new_experiment("test", "test1")
exp_loaded = load_experiment_by_name("test", "test1")

# The following will work
meas = SweepMeasurement(exp=exp_loaded)
with meas.run() as datasaver: 
    pass

# This time we will have an error
with meas.run() as datasaver: 
    pass
```
If the experiment was already there in the database, the first measurement will also fail.  


Discussion:
![image](https://user-images.githubusercontent.com/10454668/37153920-90682b64-22de-11e8-881f-0018af843843.png)

In the first instance, this seems to be caused by line 242 of the experiment_container module. We need to change 

```python
e.exp_id = rows[0]['exp_id']
```

to 

```python
e.id = rows[0]['exp_id']
```

However, we do not know how much of the code relies on the presence of the "exp_id" property being present. So we need to *add* this line instead of replacing the previous one. 
Additionally, the fact that the first run does seem to work is weird and needs looking into as well. 

Finally, tests need to be written to verify that this problem has been solved. 

Resolving patch:
diff --git a/qcodes/dataset/measurements.py b/qcodes/dataset/measurements.py
--- a/qcodes/dataset/measurements.py
+++ b/qcodes/dataset/measurements.py
@@ -219,7 +219,7 @@ def __enter__(self) -> DataSaver:
 
         # next set up the "datasaver"
         if self.experiment:
-            eid = self.experiment.id
+            eid = self.experiment.exp_id
         else:
             eid = None
 


Test patch:
diff --git a/qcodes/tests/dataset/test_experiment_container.py b/qcodes/tests/dataset/test_experiment_container.py
new file mode 100644
--- /dev/null
+++ b/qcodes/tests/dataset/test_experiment_container.py
@@ -0,0 +1,41 @@
+import pytest
+import tempfile
+import os
+
+import qcodes as qc
+from qcodes.dataset.experiment_container import load_experiment_by_name, \
+    new_experiment
+from qcodes.dataset.sqlite_base import connect, init_db
+from qcodes.dataset.measurements import Measurement
+
+
+@pytest.fixture(scope="function")
+def empty_temp_db():
+    # create a temp database for testing
+    with tempfile.TemporaryDirectory() as tmpdirname:
+        qc.config["core"]["db_location"] = os.path.join(tmpdirname, 'temp.db')
+        qc.config["core"]["db_debug"] = True
+        # this is somewhat annoying but these module scope variables
+        # are initialized at import time so they need to be overwritten
+        qc.dataset.experiment_container.DB = qc.config["core"]["db_location"]
+        qc.dataset.data_set.DB = qc.config["core"]["db_location"]
+        qc.dataset.experiment_container.debug_db = qc.config["core"]["db_debug"]
+        _c = connect(qc.config["core"]["db_location"], qc.config["core"]["db_debug"])
+        init_db(_c)
+        _c.close()
+        yield
+
+
+def test_run_loaded_experiment(empty_temp_db):
+    """
+    Test that we can resume a measurement after loading by name
+    """
+    new_experiment("test", "test1")
+    exp_loaded = load_experiment_by_name("test", "test1")
+
+    meas = Measurement(exp=exp_loaded)
+    with meas.run():
+        pass
+
+    with meas.run():
+        pass