Assignment #4 – Entity Framework

Objectives

Use an Object Relational Management System (ORM)  to manage code/database relations

Support Outcome #2 – Ability to Design, Build, and Deploy a Database Driven Client-Server Web Application.

Assignment

Note: You may complete this assignment using MVC, Web Forms, or any other suitable framework that allows for object management and CRUD operations between the application and the database.

You are going to create a data model that contains at least one 1:n relationship and at least one n:n relationship. Some examples are given below. This data model will be coded using Code First methodology. You will need to create a Model which represents each of these data entities and also the relationship between the entities.

You will create a controller and a view to allow CRUD operations on each of these entities. You will upload this (it can be in your base project) to Azure and post the object/object links so that I can test them.

Information

ORM – Object Relational Management is important for you to know. In code you work with objects, in the database you work with tables. An ORM is a framework that manages working with these different types of structures in building an application. Read the article at Wikipedia https://en.wikipedia.org/wiki/Object-relational_mapping that describes mapping between objects and tables.  Microsoft answer to this is Entity Framework.

Entity Framework (EF) is an object-relational mapper that enables .NET developers to work with relational data using domain-specific objects. It eliminates the need for most of the data-access code that developers usually need to write.

Django is an ORM that is open source and is available for PHP. 

Before starting any project in any framework and language you should have some familiarity with available ORM’s for that platform.  

I have written an Object framework that stores all Objects as XML is a single table. Getting Started – Using the XmlPropertyObject for COP4834 covers the framework and its use. I have used it successfully on many projects.

You are not limited in what example you use to demonstrate a functioning 1:n and n:n relationship. Some possible entities that you could use for this (feel free to use your own) are;

One to n (1:n)

Course Schedule – single student, multiple classes

Course Roster – Single section of a class, multiple students enrolled

Many to Many (n:n)

Gradesheet – multiple students (n) with multiple assignments (n)

Here is a sample Gradesheet example  – Creating N to N Relationships 

Other ORM Tools

There are many ORM tools on the market. You are learning EF for this assignment, but may need to be able to use other tools such as;

Estimated Completion Time

You will need to go through the MVA video on EF  – this will prepare you adequately for the work. Outside of that the coding takes about 1-2 hours for a reasonable experienced programmer.

Supporting Lectures 

Implementing Entity Framework in MVC

Lecture – Menu Case Study Part 1 – Using MVC to Create Entry Screens – This lecture I created covers creating 1:n relations all the way from project start using an existing data model and Code First.

Questions and Answers

External Resources

Introduction to Entity Framework – https://msdn.microsoft.com/en-us/library/aa937723(v=vs.113).aspx 

CRUD Operations in Visual Studio 2013 – https://code.msdn.microsoft.com/MVC5-Demo-with-Entity-c6bc81df 

Microsoft Virtual Academy Entity Framework – https://mva.microsoft.com/en-us/training-courses/implementing-entity-framework-with-mvc-8931 

Grading Criteria

5 points for demonstrating 1:n operation correctly

5 points for demonstrating n:n operation correctly