1 / 32

Intro to Entity Framework

Intro to Entity Framework. Don’t drown in database design during development. By Shahed Chowdhuri. WakeUpAndCode.com. @ shahedC. Welcome, GWU GCC Students!. Tech Check. Are you familiar with …?. Entity Framework (ORM from Microsoft). Object Relational Mapping (ORM).

iolana
Download Presentation

Intro to Entity Framework

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Intro to Entity Framework Don’t drown in database design during development By Shahed Chowdhuri WakeUpAndCode.com @shahedC

  2. Welcome, GWU GCC Students!

  3. Tech Check Are you familiar with…? Entity Framework (ORM from Microsoft) Object Relational Mapping (ORM) Web Application Development e.g. ASP.NET MVC

  4. You Should Know… • Object-Oriented Programming (e.g. C#) • Visual IDE (e.g. Visual Studio) • Software Frameworks (e.g. Microsoft .NET) • Relational Databases (e.g. SQL Server)

  5. Object-Relational Mapping

  6. Top Choices Good Comparison: http://www.dennisdoomen.net/2013/03/entity-framework-56-vs-nhibernate-3.html

  7. Working with EF

  8. A. Database-First (EDMX) ASP.NET MVC app code DB updates EDMX Model DB ADO.NET Entity Data Model (EDMX) Code uses EDMX

  9. A1. Generate EDMX

  10. A2. Update Model From Database

  11. B. Model-First (Visual Designer) Source: MSDN

  12. C.Code-First (automatic migrations) ASP.NET MVC app code uses .NET models (hand-coded) generates auto- updates Migration code (auto-generated) DB

  13. D. Code-First (manual migrations) ASP.NET MVC app code uses .NET models (hand-coded) generates manually updates Migration code (auto-generated) DB

  14. What are we trying to solve?

  15. Conflicts Within Organization DB Architects Dev Team X Dev Team Y Your Dev Team DB Admins

  16. Main Agenda

  17. 1. NuGet Package Manager

  18. 2. Entity Framework

  19. 3. Models & Mapping

  20. 4a. Connection Strings For more info: http://wakeupandcode.com/all-your-database-are-belong-to-us/

  21. 4b. Connection Strings (explained) • How can I point to my own DB? • Each dev has own ConnectionStrings.config • How do I avoid checking in to Source Control? • Remove file from .csproj, keep it local • How will server deployments work? • Use XML Transforms, i.e. Web.Prod.Config • Do I have to include credentials in .config? • No, use machine access to SQL server instead For more info: http://wakeupandcode.com/all-your-database-are-belong-to-us/

  22. 5a. Enable Migrations

  23. 5b. Update Database model code migration code dev DB migration code + seed (sql)

  24. 5c. Push Code + Migrate Server DB code push code code pull code CI Server DB migrate.exe

  25. 6. Process Workflow communication DB DB architects dev teams

  26. Additional Topics

  27. Relationships DBContext .OnModelCreating() Source: Excella Lean presentation https://github.com/excellaco/ExcellaLean

  28. Data-Annotation Attributes Source: MSDN

  29. Conclusion

  30. Downloads http://wakeupandcode.com/downloads/

  31. Online Resources • Entity Framework on MSDN • http://msdn.microsoft.com/en-us/data/ef.aspx • 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/ • Nhibernatevs Entity Framwork: • http://www.dennisdoomen.net/2013/03/entity-framework-56-vs-nhibernate-3.html • My blog post on EF Code First Migrations: • http://wakeupandcode.com/entity-framework-code-first-migrations/ • Code First Data Annotations (Julie Lerman) • http://msdn.microsoft.com/en-us/data/jj591583.aspx • Data Annotations in the Entity Framework (MSDN) • http://blogs.msdn.com/b/efdesign/archive/2010/03/30/data-annotations-in-the-entity-framework-and-code-first.aspx

  32. Questions? http://WakeUpAndCode.com @shahedC

More Related