<h3>Create two projects</h3>
-
Creating two projects in one Solution, which including a SQL Server Project, and a Web Api Project.
<h3>SQL Server Project</h3>
-
Install <code>EntityFramework</code>. from NuGet Package Management, and <code>Entity Framework Reverse POCO</code> from Extension and Updates in the menu of Tools.
-
Create a database from your SSMS(SQL Server Management Studio)
-
Import the Database you just created to the SQL Server Project.
-
Create three tables, Student.sql, Course.sql, and StudentCourse.sql. Because student to course is the relationship of many-to-many. Here we should add a cross table between them, that is StudentCourse.sql.
-
Create Foreign Key for both of StudentId and CourseId columns.
-
Right-Click the SQL Server Project, and then Publish to the database, and don't forget to switch the platform version to appropriate one.
<h3>Web API Project</h3>
-
Create a POCO file, that actually is the <code>context</code> file.
-
Edit configuration file from your Context file.
-
Insert <code><connectionString> <add ...> </connectionString></code> to the <code>.Web.config</code> file.
-
In the folder of XXXContext.cs, find the constructor method of XXXContect class, add line inside of it.
<code>base.Configuration.ProxyCreationEnabled = false;</code>
<h3>All Set!</h3>