Developer Guide
Code first update model and deploy
Delete database MAF_dev (if existed)
At Package Manager Console (generate tables)
(a). Select MyAbilityFirst.Infrastructure.Auth
update-database ==> (create asp.net tables)
(b). Select MyAbilityFirst.Infrastructure.Data
updata-database ==> (create all other tables)
3. Select MyAbilityFirst.Infrastructure.Data\SQL
a. Select seed.sql
b. Connect SQL Server(local or Azure), Select database name: MAF_dev
c. Execute
Add or Change model
get-migrations (check migrations status)
get-help entityframework (help)
Add new table (model)
At \MyAbilityFirst.Infrastructure.Data
In the class MyAbilityFirstDbContext Add: (for example) public DbSet UserAttachments { get; set; }
In the OnModelCreating(DbModelBuilder modelBuilder) Add:(for example) modelBuilder.Entity().ToTable("UserAttachment");
Change table (model)
At \MyAbilityFirst.Infrastructure.Data
add-migration name: AddUrltoTablePicture (for example)
<<Change anything in up() function which generated>>
update-database
Delete bad Migration
At \MyAbilityFirst.Infrastructure.Data
Update-database -TargetMigration: [last good migration name]
Select bad migration, mouse right key, Exclude from project (or delete bad in VS and remove code in .csproj)
update-database
Check _MigratonHistory table and .csproj
Add-Migration [full name of migration] -Force
Merge two branch
At migration folder, select and add some migration have not include in VS.
Update-database -TargetMigration: [second last good migration name]
Exclude new migrations from project
Include one by one migration Add-Migration [full name of migration]
Deploy to Azure
In VS, Open Solution Exploer window
Mouse right key menu, select Publish
At Profile tag, select Microsoft Azure App Service as publish target
*** Do not forget to change "connectionString" for local or Azure ***