c# - How to properly add an ADO.NET data model to a Web API? -


coming winforms, total beginner in asp.net , web api. i've started creating empty web api project in visual studio. connect existing database.

in winforms, typically have separate class library - data access layer or that, can have .edmx file.

now in current project, have models folder. not sure proper way it, can see can create data model there. way go?

and second question: supposed create other model classes in folder?

i mean in database might have students table lets 20 columns, in project might have case might need instance of students 2 properties (it's not best example...i know).

  1. create project entities entity framework. when right click on project can select add new -> ado.net entity data model. can either pick design database or code first database. although design easier recommend code first because it's more flexible , ef7 on edmx no longer supported.
  2. create second project api. can first adding asp.net web application , in second screen select web api. can add web api 2 controller using entity framework.
  3. reference entities project in web api.

you can find more information on web api entity framework here.


Comments