Open jadjare opened 8 years ago
Er... this maybe one for JC... This is my first foray into EF7 too..
I'm hoping to get some time to do a little research later see what else I can dig up.
Hi guys,
Did a little research on the subject... it looks like we should use migrations at some point in the near future, but for now calling Database.EnsureDeleted() before calling Database.EnsureCreated().
The "postgres" user is the owner of the database, which is configured with a password of "password". I've updated develop to call EnsureDeleted() and connect with the postgres user which gets us over the problem for now.
Of course some changes to be made in the near future...
FYI (if your interested)... the puppet postgres configuration is made in the following file puppet\modules\profiles\manifests\openrms-db.pp
All the reference for the settings are here https://github.com/puppetlabs/puppetlabs-postgresql
Pull/merge develop into your feature branches to get the fix.
Well done John, cheers for looking into this.
I'll need to read up on code migrations in EF7, see if they've changed much... I couldn't be doing with them in EF6, preferred just to get direct control of the db and use a db project, especially when it came to handling stored procedures, indexes, etc. When using PostgreSql we won't get SSDT Database Projects - Sqitch anyone (http://Sqitch.org)! ....
Mind you this is all something that we can discuss/worry about later. For now just glad it's working...
..p.s. I'll have a nose around the puppet script, as I wondered where permissions on the login were being scripted.
After adding a new property (requiring persistence) to the Item class in the domain model, I hit a problem with how best to update the database to accept the change. (Note, in hindsight, this may have also been influencing some of the problems reported in issue #29 )
The Database.EnsureCreated() method in the service start up class only creates the database if it doesn't exist. It appears in EF7/Core there is no DropCreateIfModelChanged support.
I tried simply adding an EnsureDeleted call prior to the EnsureCreated but Postgres moaned about permissions and unfortunately I don't know enough about how to manage this in Postgres at the moment.
I also tried adding a Database.Migrate() call, but this requires first of all creating CodeFirst Migrations from the command line (using the command "migrations add" - didn't work for me, but probably typed the command in the wrong context) (see http://stackoverflow.com/questions/31216983/update-database-after-model-changes-entity-framework-7)
Again any help, pointing in the right direction would be greatly received.