Custom Entity Install Drupal 9.1
The fist thing we have to do to get the block of code to work is update the drupal version in our .info file.
If you try to install the module now two things will happen. First you will get an error that states your missing the revision metadata keys in your entity annotation. The fix for this is to put these keys in the annotation on the top of your entity class.
The second thing that happens is drupal stops execution of the install script which has the effect of not creating the entity table. If you have tried to install the module you will get this error.
The fix for this is to create the table with the minimal requirements to uninstall the module. Ssh into your sever run mysql -u username -p and hit return. Type in your password. Type in use database then create table table_name (vid int(10) unsigned NOT NULL AUTO_INCREMENT, id tinyint(1) NOT NULL, PRIMARY KEY (vid)); Changing the username, password, database and table_name to yours. After you can get to the uninstall page again uninstall the module and reinstall it. You might need to go to configuration/performance and clear the cache at different points while working through this tutorial. All it deos is clear all the caches and forces Drupal to rebuild them when you request the next page.
Fixing Revisions
The other fix I found it needs out of the box is the revisions classes that deal with reverting a revision and deleting a revision. The answers I found I got from the node module in core. You can find a lot of code to use as a guild from simply looking for a core module that implements the functionality you need. I pulled my admin menu code from drupal commerce.
Before we get into that there is another fix we need to take care of first. This one has to do with the linking in the entity controller. After you install the module go to stucture/YourEntity List and create a new entity. There will only be a name so fill that in then hit save. Then head back to the list and click on the name to get to the task menu with the revisions link. Here is the next error to fix.
The error is pointing to line 127 in the controller code so this is where we will start. Also I will fix the code on line 121.
Here are the errors for the revert and the delete revisions. The fix for these is to add a __construct and properties then use them to implement the functionality in DocsRevisionDeleteForm and DocsRevisionRevertForm classes.
So far this is all I have seen to fix though I am not making use of entity settings because I am creating all the form fields programmatically and thus I am taking out the settings functionality from the module. I will look it over and put up the fixes if it needs any. It might just have been a mis-spelled property. In buildForm the $this->docsStorage property was spelled like $this->DocsStorage. Bringing in TimeInterface and DateFormatterInterface helped to get the code more dependence injection though so it works.