Add a new folder named “Model” to the project. 6. In the Models folder, add a class named Product. 7. Add a few properties like Id, Name, Description, and Price to the product class. The product should also be of some kind and for that, a category model is defined and a CategoryId property is added to the product model. 8. Similarly, add a Category model with properties like Id, Name, Description, Price

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Add a new folder named “Model” to the project.
6. In the Models folder, add a class named Product.
7. Add a few properties like Id, Name, Description, and Price to the product class. The product should also be of some kind and for that, a category model is defined and a CategoryId property is added to the product model.
8. Similarly, add a Category model with properties like Id, Name, Description, Price

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

Add a new folder named Repository in the project and add an Interface name IProductRepository in that folder. Add the methods in the interface that performs CRUD operations for Product microservice. 

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

Add a connection string in the appsettings.json file.
Open the Startup.cs file to add the SQL server db provider for EF Core. Add the code services.AddDbContext<ProductContext>(o => o.UseSqlServer(Configuration.GetConnectionString("ProductDB"))); under ConfigureServices method. Note that in the GetConnectionString method the name of the key of the connection string is passed that was added in appsettings file. 

Solution
Bartleby Expert
SEE SOLUTION
Follow-up Question

Instructions: Though the .NET Core API project has inbuilt support for EF Core and all the related dependencies are downloaded at the time of project creation and compilation which could be found under the SDK section in the project as shown below.
Microsoft.EntityFrameworkCore.SqlServer (2.1.1) should be the package inside the downloaded SDKs. If it is not present, it could be explicitly added to the project via Nuget Packages.
9. Add a new folder named DBContexts to the project.
10. Add a new class named ProductContext which includes the DbSet properties for Products and Categories. OnModelCreating is a method via which the master data could be seeded to the database. So, add the OnModelCreating method and add some sample categories that will be added to the database initially into the category table when the database is created. 

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Development strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education