Developer Guide
Code first update model and deploy
Bulid database
Delete database MAF_dev (if existed)
At Package Manager Console (generate tables)
(a). Select MyAbilityFirst.Infrastructure.Auth
(b). Select MyAbilityFirst.Infrastructure.Data
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
Update
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]
Finally, update-database
Deploy to Azure
In VS, Open Solution Exploer window
Select defalut project
Mouse right key menu, select Publish
At Profile tag, select Microsoft Azure App Service as publish target
Publish
*** Do not forget to change "connectionString" for local or Azure ***
Last updated