Introduction to the Entity Framework
Create an MVC application called EFIntroductionMVC using the -o option
Create a new controller called HousePartyController
Create a model called HousePartyInvitee with the following properties:
HousePartyInvitee:
- id - int
- vipName - string
- isAttending - bool
- numberOfHousePartiesAttended - int
- age - int
- Create a
DbContextcalledInviteeContextin new subdirectory calledDao - Create a
DbSetcalledInvitees- Create a Sqlite configuration string in
appsettings.jsonusing
"ConnectionStrings" : { "DefaultDBConnection" : "DataSource=blog.db" } - Create a Sqlite configuration string in
- Run the entity framework commands to:
- Create Migrations
- Apply migrations to the database
- Use the Sqlite Plug-in to ensure the database was created
- In your controller implement the following endpoints:
ListInvites that will return a simple list (using Content()) of all invites in the database
AddInvite that will accept a POST message with the properties in the body and create a new invite in database
ModifyInvite that will accept a PUT message with the properties in the body and update an existing invite in database that matches the passed in vipName
DeleteInvite that will accept a DELETE message and an vipName and delete the matching invite from the database by vipName
- Create PostMan Tests for all cases and export to your repo
Create a console application called EFIntroduction using the -o option
Create a wrapper class called EFIntroductionWrapper
Create a model called Product with the following properties:
Product:
- productID - int
- productName - string
- price - string
- quantity - string
- Create a
DbContextcalledProductContext- Use Sqlite configuration with a
Data Sourceequal toproducts.db
- Use Sqlite configuration with a
- Create a
DbSetcalledProducts - Run the entity framework commands to:
- Create Migrations
- Apply migrations to the database
- Use the Sqlite Plug-in to ensure the database was created
- Instantiate your
EFIntroductionWrapperwrapper class- Add a method to your wrapper class that:
- Creates 3 products in the database then lists all the products from the database
- Queries the database and just returns one Product given a specific product name to filter on and prints it out
- Update the
quantityof the product retrieved in #2 and prints out the updated product - Delete the product retrieved in #2 and print all the remaining products