How to build it
Read more- Add a database in SQL named DemoApp
- Add some data to the table named Product
- Go to Visual Studio
- Add a ASP.NET Web API
- Right click on the Controllers folder
- Add a Web API 2 Controller
- Add a class library to the solution and name it ProductsDataAccess
- Remove the old class and add a ADO.NET Entity Data Model
- Name it DataModel
- There is a popup will appear to connect to the database of your choosing.
- Choose Microsoft SQL Server.
- Enter the server name.
- Choose the database DemoApp.
- Click Next.
- Test the connection by click to Test Connection button.
- Choose the table Product.
- Click Finish.
Go to the DataModel.Context.cs and make use you have:
public virtual DbSet<Product> Products {get; set;}
Comments
Please log in or sign up to comment.