c# - Azure Mobile Service - Entity Framework Code First drop and create database not working -
problem: changing model in code first mobile services project , publishing azure causes following error:
system.data.sqlclient.sqlexception (0x80131904): cannot open database "master" requested login. login failed. login failed user 'xxxxxxxxxxxxxxxxxx'.
steps reproduce:
- visual studio community 2015 new project -> web application -> mobile service
- publish straight azure (create new mobile service - select cheapest tier db)
- send in fiddler http://whatever.azure-mobile.net/tables/todoitem
- receive 200 ok 2 items seeded db default project
- make small change model (e.g. add following todoitem class) public string changed { get; set; }
- publish changes azure
- send in fiddler http://whatever.azure-mobile.net/tables/todoitem
- this time 500 internal server error received , error quoted @ start appears twice in mobile service logs in azure
i have checked , database still exists without change model, assume azure wasn't able drop reason.
in default mobile service project, in webapiconfig class database initializer set of type inherits dropcreatedatabaseifmodelchanges. shouldn't azure drop database , recreate it? had problem in customised project of mine, tried test default mobile service , able reproduce it, shouldn't default site work outside of box, @ least?
is there need allow azure drop database? error message suggests can't log in, we've proven can fact seed method in mobileserviceinitializer class called when service first published (because able return 2 todoitems first request sent fiddler).
any ideas? appreciated, thanks.
found answer right after submitting this, typical!
the db user azure uses doesn't have permission drop database, need change type of initializer used dropcreatedatabaseifmodelchanges cleardatabaseschemaifmodelchanges. updates schema nicely on every deployment!
Comments
Post a Comment