16
Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Embed Size (px)

Citation preview

Page 1: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Data Access Layer ShahedChowdhuriUsing Code-First Migrations

Page 2: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Thanks to our Sponsorsfor keeping the fires lit

Page 3: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

TDD (Test Driven Development)

BDD (Behavior Driven Development)

CI (Continuous Integration)

CD (Continuous Delivery)

Introduction

ASP.NETMVC

DB

EnterpriseWebApplication

Looking for Ways to Improve & Modernize

Motivation behind this design?

Our desire to do the following:

Page 4: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Tech Check

ASP.NETMVC

EntityFramework

EF Code-First

Development

EF Code-First Migrations

Are you familiar with…?

Page 5: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Options and Alternatives

Database-First

(EDMX)

Model-First

(Visual Designer)

Code-First (automatic migrations)

Code-First (manual

migrations)

Page 6: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

What are we trying to solve?

Page 7: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

DAL: Agenda

1. Models & Mapping

2. Connection Strings

3. Enable Migrations

4. Update Database

5. Push Code + Migrate Server DB

6. Process Workflow

Page 8: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

1. Models & MappingDBContext.OnModelCreating()

Page 9: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

2. Connection Strings

Page 10: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

3. Enable Migrations

Page 11: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

migration code

4. Update Database

model code

migration code + seed

devDB

(sql)

Page 12: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

5. Push Code + Migrate Server DBcode push code

CI

code pull code

migrate.exeServer

DB

Page 13: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

6. Process Workflow

dev team DB architects

communication

DB

Page 14: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Code Walkthrough

Page 15: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

DAL: Conclusion

Code-First Migrations

Dev Team Synchronized

Server DeploymentDatabase

Versioning

Continuous Development

Page 16: Data Access Layer Shahed Chowdhuri Using Code-First Migrations

Resources

• EF Code First Migrations on MSDN:– http://msdn.microsoft.com/en-US/data/jj591621

• Web.config & configSource:– http://wakeupandcode.com/all-your-database-are-belong-to-us/

• PluralSight EF Migrations video tutorial:– http://pluralsight.com/training/Courses/TableOfContents/efmigrations