Datacontext submitchanges not updating database

When you create the repository class, you create an interface that represents all of the methods used by the repository class.Within your controllers, you write your code against the interface instead of the repository.Create Table We create a table in a database for the user to store user information.The user table creation code is as in the following: "Project...". NET MVC 4 Web Application" from the list, then provide the application name " User Registration" and set the path in the location input where you want to create the application.Step 3: Now choose the Project Template "Empty" and select "Razor" as the view engine from the dropdown list.Adding a LINQ to SQL Class Entity classes are created and stored in LINQ to SQL Classes files (files). It is a Data Context class that contains methods and properties for connecting to a database and manipulating the data in the database.Create Controller and Views for User CRUD operations You need to create a controller to handle the request from the browser.In this application I created the "User Controller" controller under the Controllers folder.

A repository class contains the specialized data access methods required for its corresponding domain model entity.We need the following "using" in the controller to perform CRUD operations: We create an instance of the User Repository interface in the User Controller and initialize the user repository in the constructor of the user Controller (User Controller.cs) as in the following:private IUser Repository _repository; We will use Scaffold templates to create a view for the CRUD operations.We use five scaffold templates, List, Create, Edit, Delete and Details.That way, you can implement the repository using various data access technologies in the future.So first of all you need to create an interface "IUser Repository" under the Models folder that contains basic CRUD operations access methods for user.

Leave a Reply