Database functionality v2 initial progress
Got models to a working state, further improvement to be made.
Got the rest of the code generation working, updated core classes to use it, cleaned up code, etc.