SlideShare a Scribd company logo
USANDO EL ENTITY
    FRAMEWORK

  Juan Camilo Sacanamboy
ENTITY FRAMEWORK




Fuente: MSDN (Working with Data in ASP.NET MVC 3)
ENTITY FRAMEWORK




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
CONTOSO UNIVERSITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
CONTOSO UNIVERSITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
CONTOSO UNIVERSITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
POCO

   • Plain Old CLR Objects
   • POCO Class  Persistence ignorance
   • Design – Build – Test
       – Independently of
            • Database
            • Persistence infrastructure code
   • Focus on the business problem


Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
DATA MODEL




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
STUDENT ENTITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
ENROLLMENT ENTITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
COURSE ENTITY




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
DATABASE CONTEXT




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
CONNECTION STRING

   • SQL Server Compact
            <add name="SchoolContext" connectionString="Data
            Source=|DataDirectory|School.sdf"
            providerName="System.Data.SqlServerCe.4.0"/>




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Initializing the Database with test data

   •   using   System;
       using   System.Collections.Generic;
       using   System.Linq;
       using   System.Web;
       using   System.Data.Entity;
       using   ContosoUniversity.Models;

       namespace ContosoUniversity.DAL
       {
           public class SchoolInitializer : DropCreateDatabaseIfModelChanges<SchoolContext>
           {
               protected override void Seed(SchoolContext context)
               {
                   var students = new List<Student>
                   {
                       new Student { FirstMidName = "Carson",   LastName = "Alexander", EnrollmentDate   =
       DateTime.Parse("2005-09-01") },
                       new Student { FirstMidName = "Meredith", LastName = "Alonso",    EnrollmentDate   =
       DateTime.Parse("2002-09-01") },
                       new Student { FirstMidName = "Arturo",   LastName = "Anand",     EnrollmentDate   =
       DateTime.Parse("2003-09-01") },
                       new Student { FirstMidName = "Gytis",    LastName = "Barzdukas", EnrollmentDate   =
       DateTime.Parse("2002-09-01") },
                       new Student { FirstMidName = "Yan",      LastName = "Li",        EnrollmentDate   =
       DateTime.Parse("2002-09-01") },
                       new Student { FirstMidName = "Peggy",    LastName = "Justice",   EnrollmentDate   =
       DateTime.Parse("2001-09-01") },
                       new Student { FirstMidName = "Laura",    LastName = "Norman",    EnrollmentDate   =
       DateTime.Parse("2003-09-01") },
                       new Student { FirstMidName = "Nino",     LastName = "Olivetto", EnrollmentDate    =
       DateTime.Parse("2005-09-01") }
                   };
                   students.ForEach(s => context.Students.Add(s));
                   context.SaveChanges();

Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Initializing the Database with test data

   •   var courses = new List<Course>
                  {
                      new Course { Title = "Chemistry",      Credits   =   3,   },
                      new Course { Title = "Microeconomics", Credits   =   3,   },
                      new Course { Title = "Macroeconomics", Credits   =   3,   },
                      new Course { Title = "Calculus",       Credits   =   4,   },
                      new Course { Title = "Trigonometry",   Credits   =   4,   },
                      new Course { Title = "Composition",    Credits   =   3,   },
                      new Course { Title = "Literature",     Credits   =   4,   }
                  };
                  courses.ForEach(s => context.Courses.Add(s));
                  context.SaveChanges();

                   var enrollments = new List<Enrollment>
                   {
                       new Enrollment { StudentID = 1, CourseID = 1, Grade      =   1
                                                                                    },
                       new Enrollment { StudentID = 1, CourseID = 2, Grade      =   3
                                                                                    },
                       new Enrollment { StudentID = 1, CourseID = 3, Grade      =   1
                                                                                    },
                       new Enrollment { StudentID = 2, CourseID = 4, Grade      =   2
                                                                                    },
                       new Enrollment { StudentID = 2, CourseID = 5, Grade      =   4
                                                                                    },
                       new Enrollment { StudentID = 2, CourseID = 6, Grade      =   4
                                                                                    },
                       new Enrollment { StudentID = 3, CourseID = 1                 },
                       new Enrollment { StudentID = 4, CourseID = 1,                },
                       new Enrollment { StudentID = 4, CourseID = 2, Grade      = 4 },
                       new Enrollment { StudentID = 5, CourseID = 3, Grade      = 3 },
                       new Enrollment { StudentID = 6, CourseID = 4                 },
                       new Enrollment { StudentID = 7, CourseID = 5, Grade      = 2 },
                   };
                   enrollments.ForEach(s => context.Enrollments.Add(s));
                   context.SaveChanges();
               }
           }
       }

Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Global.asax.cs




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Creating a Student Controller




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
StudentController.cs




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
ViewsStudentIndex.cshtml

   •   @model IEnumerable<ContosoUniversity.Models.Student>

       @{
             ViewBag.Title = "Students";
       }

       <h2>Students</h2>

       <p>
           @Html.ActionLink("Create New", "Create")
       </p>
       <table>
           <tr>
               <th></th>
               <th>Last Name</th>
               <th>First Name</th>
               <th>Enrollment Date</th>
           </tr>


Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
ViewsStudentIndex.cshtml

   •   @foreach (var item in Model) {
           <tr>
                <td>
                     @Html.ActionLink("Edit", "Edit", new { id=item.StudentID }) |
                     @Html.ActionLink("Details", "Details", new { id=item.StudentID })
       |
                     @Html.ActionLink("Delete", "Delete", new { id=item.StudentID })
                </td>
                <td>
                     @Html.DisplayFor(modelItem => item.LastName)
                </td>
                <td>
                     @Html.DisplayFor(modelItem => item.FirstMidName)
                </td>
                <td>
                     @Html.DisplayFor(modelItem => item.EnrollmentDate)
                </td>
           </tr>
       }

       </table>


Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Running application




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Solution Explorer




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Solution Explorer




Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
Conventions

• Los nombres de las entidades en plural son los
  nombres de las tablas.
• Los nombres de las propiedades de las
  entidades son las columnas de las tablas.
• Las propiedades llamadas ID o *ID son
  reconocidas como claves primarias.
• El EF se conecta a la base de datos buscando
  un string de conexión que tenga el mismo
  nombre de la clase contexto. (SchoolContext)
Usando el entity framework

More Related Content

What's hot (10)

PPT
Linq
Foyzul Karim
 
PDF
Java OOP Programming language (Part 3) - Class and Object
OUM SAOKOSAL
 
PDF
The Ring programming language version 1.5.4 book - Part 73 of 185
Mahmoud Samir Fayed
 
PPTX
R environment
Daniele Ronzani
 
PDF
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
scalaconfjp
 
PPTX
11. session 11 functions and objects
Phúc Đỗ
 
PDF
The Ring programming language version 1.5.2 book - Part 70 of 181
Mahmoud Samir Fayed
 
PPT
06slide
DEEPIKA KAMBOJ
 
PPTX
Ggplot2 v3
Josh Doyle
 
PDF
Scala Domain Modeling and Architecture
Hossam Karim
 
Java OOP Programming language (Part 3) - Class and Object
OUM SAOKOSAL
 
The Ring programming language version 1.5.4 book - Part 73 of 185
Mahmoud Samir Fayed
 
R environment
Daniele Ronzani
 
Functional Object-Oriented Imperative Scala / 関数型オブジェクト指向命令型 Scala by Sébasti...
scalaconfjp
 
11. session 11 functions and objects
Phúc Đỗ
 
The Ring programming language version 1.5.2 book - Part 70 of 181
Mahmoud Samir Fayed
 
Ggplot2 v3
Josh Doyle
 
Scala Domain Modeling and Architecture
Hossam Karim
 

Viewers also liked (6)

PDF
UX for developers
Juan Camilo Sacanamboy
 
PDF
Keep calm and write reusable code in Android
Juan Camilo Sacanamboy
 
PDF
Problema del barbero durmiente
Juan Camilo Sacanamboy
 
PDF
Modelado de circuitos con ED de orden superior
Juan Camilo Sacanamboy
 
UX for developers
Juan Camilo Sacanamboy
 
Keep calm and write reusable code in Android
Juan Camilo Sacanamboy
 
Problema del barbero durmiente
Juan Camilo Sacanamboy
 
Modelado de circuitos con ED de orden superior
Juan Camilo Sacanamboy
 
Ad

Similar to Usando el entity framework (20)

PDF
662305 09
Nitigan Nakjuatong
 
PDF
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
DEEPANSHU GUPTA
 
PPT
Servlet ParameterData getParameterName getValues
MMichealBerdinanth
 
PDF
Hello Swift Final 5/5 - Structures and Classes
Cody Yun
 
PPTX
Java Foundations: Objects and Classes
Svetlin Nakov
 
PDF
An introduction into Spring Data
Oliver Gierke
 
PDF
Paintfree Object-Document Mapping for MongoDB by Philipp Krenn
JavaDayUA
 
PDF
Data access 2.0? Please welcome: Spring Data!
Oliver Gierke
 
PDF
Modul Praktek Java OOP
Zaenal Arifin
 
PDF
Java questionI am having issues returning the score sort in numeri.pdf
forwardcom41
 
PDF
How to implement g rpc services in nodejs
Katy Slemon
 
PPT
Spring data
명철 강
 
PPTX
Lecture_4_Static_variables_and_Methods.pptx
IkaDeviPerwitasari1
 
PPTX
11. Java Objects and classes
Intro C# Book
 
DOCX
Tutorial mvc (pelajari ini jika ingin tahu mvc) keren
Sony Suci
 
PPTX
array of object pointer in c++
Arpita Patel
 
PPT
Spsl v unit - final
Sasidhar Kothuru
 
PPT
Spsl vi unit final
Sasidhar Kothuru
 
PDF
[PL] O klasycznej, programistycznej elegancji
Jakub Marchwicki
 
PPTX
03 object-classes-pbl-4-slots
mha4
 
APPLICATION TO DOCUMENT ALL THE DETAILS OF JAVA CLASSES OF A PROJECT AT ONCE...
DEEPANSHU GUPTA
 
Servlet ParameterData getParameterName getValues
MMichealBerdinanth
 
Hello Swift Final 5/5 - Structures and Classes
Cody Yun
 
Java Foundations: Objects and Classes
Svetlin Nakov
 
An introduction into Spring Data
Oliver Gierke
 
Paintfree Object-Document Mapping for MongoDB by Philipp Krenn
JavaDayUA
 
Data access 2.0? Please welcome: Spring Data!
Oliver Gierke
 
Modul Praktek Java OOP
Zaenal Arifin
 
Java questionI am having issues returning the score sort in numeri.pdf
forwardcom41
 
How to implement g rpc services in nodejs
Katy Slemon
 
Spring data
명철 강
 
Lecture_4_Static_variables_and_Methods.pptx
IkaDeviPerwitasari1
 
11. Java Objects and classes
Intro C# Book
 
Tutorial mvc (pelajari ini jika ingin tahu mvc) keren
Sony Suci
 
array of object pointer in c++
Arpita Patel
 
Spsl v unit - final
Sasidhar Kothuru
 
Spsl vi unit final
Sasidhar Kothuru
 
[PL] O klasycznej, programistycznej elegancji
Jakub Marchwicki
 
03 object-classes-pbl-4-slots
mha4
 
Ad

More from Juan Camilo Sacanamboy (8)

PDF
OFDM (Orthogonal Frequency Division Multiplexing )
Juan Camilo Sacanamboy
 
PDF
Functional Testing
Juan Camilo Sacanamboy
 
PDF
FTP (File Transfer Protocol)
Juan Camilo Sacanamboy
 
PDF
Protocolo de Enrutamiento RIP (Versiones 1 y 2)
Juan Camilo Sacanamboy
 
PDF
Infrarrojo
Juan Camilo Sacanamboy
 
PDF
Ecuación de bessel
Juan Camilo Sacanamboy
 
PDF
Algoritmo JPEG
Juan Camilo Sacanamboy
 
PDF
Tutorial ASP .NET
Juan Camilo Sacanamboy
 
OFDM (Orthogonal Frequency Division Multiplexing )
Juan Camilo Sacanamboy
 
Functional Testing
Juan Camilo Sacanamboy
 
FTP (File Transfer Protocol)
Juan Camilo Sacanamboy
 
Protocolo de Enrutamiento RIP (Versiones 1 y 2)
Juan Camilo Sacanamboy
 
Ecuación de bessel
Juan Camilo Sacanamboy
 
Algoritmo JPEG
Juan Camilo Sacanamboy
 
Tutorial ASP .NET
Juan Camilo Sacanamboy
 

Recently uploaded (20)

PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PDF
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
PDF
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
PDF
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
Researching The Best Chat SDK Providers in 2025
Ray Fields
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
RAT Builders - How to Catch Them All [DeepSec 2024]
malmoeb
 
Data_Analytics_vs_Data_Science_vs_BI_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
NewMind AI Weekly Chronicles – July’25, Week III
NewMind AI
 
Build with AI and GDG Cloud Bydgoszcz- ADK .pdf
jaroslawgajewski1
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
TrustArc Webinar - Navigating Data Privacy in LATAM: Laws, Trends, and Compli...
TrustArc
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 

Usando el entity framework

  • 1. USANDO EL ENTITY FRAMEWORK Juan Camilo Sacanamboy
  • 2. ENTITY FRAMEWORK Fuente: MSDN (Working with Data in ASP.NET MVC 3)
  • 3. ENTITY FRAMEWORK Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 4. CONTOSO UNIVERSITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 5. CONTOSO UNIVERSITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 6. CONTOSO UNIVERSITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 7. POCO • Plain Old CLR Objects • POCO Class  Persistence ignorance • Design – Build – Test – Independently of • Database • Persistence infrastructure code • Focus on the business problem Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 8. DATA MODEL Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 9. STUDENT ENTITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 10. ENROLLMENT ENTITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 11. COURSE ENTITY Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 12. DATABASE CONTEXT Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 13. CONNECTION STRING • SQL Server Compact <add name="SchoolContext" connectionString="Data Source=|DataDirectory|School.sdf" providerName="System.Data.SqlServerCe.4.0"/> Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 14. Initializing the Database with test data • using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data.Entity; using ContosoUniversity.Models; namespace ContosoUniversity.DAL { public class SchoolInitializer : DropCreateDatabaseIfModelChanges<SchoolContext> { protected override void Seed(SchoolContext context) { var students = new List<Student> { new Student { FirstMidName = "Carson", LastName = "Alexander", EnrollmentDate = DateTime.Parse("2005-09-01") }, new Student { FirstMidName = "Meredith", LastName = "Alonso", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Arturo", LastName = "Anand", EnrollmentDate = DateTime.Parse("2003-09-01") }, new Student { FirstMidName = "Gytis", LastName = "Barzdukas", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Yan", LastName = "Li", EnrollmentDate = DateTime.Parse("2002-09-01") }, new Student { FirstMidName = "Peggy", LastName = "Justice", EnrollmentDate = DateTime.Parse("2001-09-01") }, new Student { FirstMidName = "Laura", LastName = "Norman", EnrollmentDate = DateTime.Parse("2003-09-01") }, new Student { FirstMidName = "Nino", LastName = "Olivetto", EnrollmentDate = DateTime.Parse("2005-09-01") } }; students.ForEach(s => context.Students.Add(s)); context.SaveChanges(); Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 15. Initializing the Database with test data • var courses = new List<Course> { new Course { Title = "Chemistry", Credits = 3, }, new Course { Title = "Microeconomics", Credits = 3, }, new Course { Title = "Macroeconomics", Credits = 3, }, new Course { Title = "Calculus", Credits = 4, }, new Course { Title = "Trigonometry", Credits = 4, }, new Course { Title = "Composition", Credits = 3, }, new Course { Title = "Literature", Credits = 4, } }; courses.ForEach(s => context.Courses.Add(s)); context.SaveChanges(); var enrollments = new List<Enrollment> { new Enrollment { StudentID = 1, CourseID = 1, Grade = 1 }, new Enrollment { StudentID = 1, CourseID = 2, Grade = 3 }, new Enrollment { StudentID = 1, CourseID = 3, Grade = 1 }, new Enrollment { StudentID = 2, CourseID = 4, Grade = 2 }, new Enrollment { StudentID = 2, CourseID = 5, Grade = 4 }, new Enrollment { StudentID = 2, CourseID = 6, Grade = 4 }, new Enrollment { StudentID = 3, CourseID = 1 }, new Enrollment { StudentID = 4, CourseID = 1, }, new Enrollment { StudentID = 4, CourseID = 2, Grade = 4 }, new Enrollment { StudentID = 5, CourseID = 3, Grade = 3 }, new Enrollment { StudentID = 6, CourseID = 4 }, new Enrollment { StudentID = 7, CourseID = 5, Grade = 2 }, }; enrollments.ForEach(s => context.Enrollments.Add(s)); context.SaveChanges(); } } } Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 16. Global.asax.cs Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 17. Creating a Student Controller Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 18. StudentController.cs Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 19. ViewsStudentIndex.cshtml • @model IEnumerable<ContosoUniversity.Models.Student> @{ ViewBag.Title = "Students"; } <h2>Students</h2> <p> @Html.ActionLink("Create New", "Create") </p> <table> <tr> <th></th> <th>Last Name</th> <th>First Name</th> <th>Enrollment Date</th> </tr> Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 20. ViewsStudentIndex.cshtml • @foreach (var item in Model) { <tr> <td> @Html.ActionLink("Edit", "Edit", new { id=item.StudentID }) | @Html.ActionLink("Details", "Details", new { id=item.StudentID }) | @Html.ActionLink("Delete", "Delete", new { id=item.StudentID }) </td> <td> @Html.DisplayFor(modelItem => item.LastName) </td> <td> @Html.DisplayFor(modelItem => item.FirstMidName) </td> <td> @Html.DisplayFor(modelItem => item.EnrollmentDate) </td> </tr> } </table> Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 21. Running application Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 22. Solution Explorer Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 23. Solution Explorer Fuente: MSDN (Creating an Entity Framework Data Model for an ASP.NET MVC Application)
  • 24. Conventions • Los nombres de las entidades en plural son los nombres de las tablas. • Los nombres de las propiedades de las entidades son las columnas de las tablas. • Las propiedades llamadas ID o *ID son reconocidas como claves primarias. • El EF se conecta a la base de datos buscando un string de conexión que tenga el mismo nombre de la clase contexto. (SchoolContext)