Overview
Here I will explain a scenario in which a student can join multiple courses. To do this I am creating three tables, two master and one transaction. The tables are named Student, Course, and trnjCourse_Studnet. The Student table has student information. The Course table has a course name and course ID. The transaction table contains information about a student and courses in a one-to-many relationship. For Table, scripts click here.
Now I need to write a LINQ query for students joining multiple courses, and then the entire course name that is joined by that student should be displayed, separated by a comma with the unique student information. Let's see how to do it.
Step 1. Right-click on the project then select Add new item then select EF model as in the following.

Step 2. Provide the name of the FE model click add and select Generate from DB.

Step 3. Click Next.

Step 4. Select the table.

Step 5. After clicking Finish we will get an entity model like.

Now right-click on the project and add a web form having 1 TextBox, 1 button, and a grid view for displaying the data. Copy and paste the following code to your web form for that.
<div style="font-family: Arial;">
Student Name
<asp:TextBox ID="txtstudentName" runat="server"></asp:TextBox>
<asp:Button ID="Search" runat="server" onclick="Button1_Click" Text="Search" />
<br />
<br />
<asp:GridView ID="gvstudents" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None" AutoGenerateColumns="False">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="StudentId" HeaderText="Id" />
<asp:BoundField DataField="StudentName" HeaderText="Name" />
<asp:BoundField DataField="FatherName" HeaderText="Father Name" />
<asp:BoundField DataField="ContactNo" HeaderText="Contact No" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="courseName" HeaderText="Courses" />
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
<br />


sathish ramPosted Jan 8, 2019, 12:10 PM
Is this possible to store data in visual studio itself using entity framework]
Gowtham RajamanickamPosted May 28, 2015, 10:44 AM
this is great..