Managing a huge number of database records related to a particular entity is very difficult in today's modern applications. For example,one customer can purchase multiple types of items, so in this case case the customer is a single entity and the items he is purchasing are different entities having multiple records with dynamic entries where we don't know the count. So in this scenario it's very difficult to manage the database table structure, so this article is related to Solve this issue .
Follow the following steps in order to implement “Bulk Data Insertion in ASPMVC”.
Follow the following steps in order to implement “Bulk Data Insertion in ASPMVC”.
Step-1 : Create Following tables in SQL Server
Here I have Created 2 tables – 1) the First table that you are watching in the image(image 2) is PerosnalDetails Table. 2) The second Table that you are watching in the image (image 1) is QualificationTbl. 1st Image is the Output of that Form From where I will insert records in these tables.
Here, with the help of this form, i will fill students records(Personal+Qualifications).A Student can have more than one qualifications so here we have to use "Concept" Bulk Data Insertion.
Step 1: Create an MVC Application.
Now let us start with a step by step approach from the creation of a simple MVC application as in the following:
- create a New ASPMVC4 Application Named "MVCApplication46"
- Go to File->New->Project->ASP.NET MVC4 Web Application .Then Provide the Project Name as you wish.After clicking, the following window will appear :
- As shown in the preceding screenshot, click on the Basic template, then click OK. This will create an empty MVC web application.
Step 2: Add The Reference of Dapper ORM into Project.
Now the next step is to add the reference of Dapper ORM into our created MVC Project. Here are the steps:
Right click on Solution, find Manage NuGet Package manager and click on it.
- After as shown in the image and type in search box "dapper".
- Select Dapper as shown in the image.
- Choose the version of the dapper library and click on install button.
After installing the Dapper library, it will be added into the References of our solution explorer of MVC application such as:
Step 3: Create Model Class.
Now let's create the model class named PerosnalDetails.cs by right-clicking on model folder and
also, Create one More Class To Map Students With Qualifications - QualificationDetails.cs
Go to Solution Explorer -> Right Click on Models Folder ->Add -> Class ->Write the Name of class “PerosnalDetails.cs”.
Note:
It is not mandatory that Model class should be in Models folder, it is just for better readability you can create this class anywhere in the solution explorer. This can be done by creating different folder names or without the folder name or in a separate class library.
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
-
- namespace MVCApplication46.Models
- {
- public class EmployeeModel
- {
- public int ID { get; set; }
- public string Name { get; set; }
- public string Dob { get; set; }
- public string State{get;set;}
- public string District{get;set;}
- public string Email{get;set;}
- public List<QualificationDetails>Products { get; set; }
- }
- public class QualificationDetails
- {
- public string ClassName{get;set;}
- public string Board { get; set; }
-
- }
- }
Step 1: Create an MVC Application.
Now let us start with a step by step approach from the creation of a simple MVC application as in the following:
- create a New ASPMVC4 Application Named "MVCApplication46"
- Go to File->New->Project->ASP.NET MVC4 Web Application .Then Provide the Project Name as you wish.After clicking, the following window will appear :
Step 2: Add The Reference of Dapper ORM into Project.
Now the next step is to add the reference of Dapper ORM into our created MVC Project. Here are the steps:
Now the next step is to add the reference of Dapper ORM into our created MVC Project. Here are the steps:
Right click on Solution, find Manage NuGet Package manager and click on it.
- After as shown in the image and type in search box "dapper".
- Select Dapper as shown in the image.
- Choose the version of the dapper library and click on install button.
After installing the Dapper library, it will be added into the References of our solution explorer of MVC application such as:
Step 3: Create Model Class.
Now let's create the model class named PerosnalDetails.cs by right-clicking on model folder and
Now let's create the model class named PerosnalDetails.cs by right-clicking on model folder and
also, Create one More Class To Map Students With Qualifications - QualificationDetails.cs
Go to Solution Explorer -> Right Click on Models Folder ->Add -> Class ->Write the Name of class “PerosnalDetails.cs”.
Note:
It is not mandatory that Model class should be in Models folder, it is just for better readability you can create this class anywhere in the solution explorer. This can be done by creating different folder names or without the folder name or in a separate class library.
It is not mandatory that Model class should be in Models folder, it is just for better readability you can create this class anywhere in the solution explorer. This can be done by creating different folder names or without the folder name or in a separate class library.
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.DataAnnotations;
- namespace MVCApplication46.Models
- {
- public class EmployeeModel
- {
- public int ID { get; set; }
- public string Name { get; set; }
- public string Dob { get; set; }
- public string State{get;set;}
- public string District{get;set;}
- public string Email{get;set;}
- public List<QualificationDetails>Products { get; set; }
- }
- public class QualificationDetails
- {
- public string ClassName{get;set;}
- public string Board { get; set; }
- }
- }
No comments:
Post a Comment