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

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter2: Formatting Workbook Text And Data
Section: Chapter Questions
Problem 1.4CP
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
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage