Posts

Showing posts from July, 2017

ASP.Net Web API with Entity Framework

Image
Part 1: Create Web API Project 1. Create a database according to your needs. 2. Create a Asp.Net Web API project. 3. Install Entity Framework from NuGet. 4. Generate model from database by adding 'ADO.Net Entity Data Model' and connecting to your database using the wizard it provides. Read how to do it:  https://docs.microsoft.com/en-us/aspnet/mvc/overview/getting-started/database-first-development/creating-the-web-application 5. Create Web API controller with actions using Entity Framework. 6. Create Data Transfer Objects to transfer data from Web API NOTE: Don't use Entity Framework models because it will gives you a serializing error Read more on DTO:  https://docs.microsoft.com/en-us/aspnet/web-api/overview/data/using-web-api-with-entity-framework/part-5 Ex: Create ProductModel to use other than Product object which created by Entity Framework 7. Change controller method's return type to newly created DTO type Original Method: publi...