How to save the definition of an entity? I am trying to figure out if there is a difference between saving an instance of an entity and saving the definition of an entity.

My use case is this:  I wrote a small module that defines an entity, which I then used in other code on my site.  All of this worked just fine, and I thought that once I had created some instances of my entity, and that those instances were stored in my database, I could then disable the little module that defined my entity.  I thought, in other words, that defining an entity would be like defining a Content Type, and that once you had done so the new entity, like a new Content Type, would "stick around".

That, however, is not how things work.  If I disable the little module that defines the new entity, that entity disappears from my system, and the code that uses that entity fails.  Re-enabling the little entity-defining module returns everything to normal and the site works again.

I think I may have missed a step here [entity_save?] but find nothing in the documentation that discusses saving the definition of a programatically defined entity.

Two more things.  First, I have noticed that the "model" module, which provides a template for creating your own entities, exhibits the same behavior that my little module did:  if I disable that module, the entities that I used it to define vanish from my system.  I have also noticed that the Entity Construction Kit [ECK] creates, in addition to the base table, two additional tables, one of which, eck_bundles, looks like it has entity properties.  I have not been willing to disable the ECK, though, because the documentation says that Drupal needs it.

Another way of posing my question would be this:  "Do you have to keep the code that defines your entity in your system, or is there some way of storing the entity definition for subsequent use?"

I am running Drupal 7.39
Yes, the module providing the entity type needs to be enabled for the entity to work correctly, and any module using that entity should include the defining module as a dependency. Drupal modules are generally not factories that produce configuration and can then go away (the major exception being modules generated with the Features module which can behave this way at times), they generally provide ongoing functionality that Drupal will expect to be available on demand.

In your case Drupal loads the class from that module under a variety of conditions (not the least of which is anytime you load an instance of that entity) and so needs to continue to be active as long as you use the entity. That module is also the place to define any special behaviors of the new type of entity you have defined (like changes to the save/load process, or other actions the entity may provide).