Step1: Install entity framework using nuget package manager.

Step2: Add a class file to the Models folder.(class name must equal connection string name and inherit DBContext,DBContext is in the namespace of System.Data.Entity)

Step3: Add a connection string, to the web.config file, in the root directory.

Step4: Map model class to the database table using "Table" atttibute.

Step5: Make the required changes to action method in controller.

Step6: Paste the following code in Application_Start() function in Global.asax file. Existing databases do not need, database initializer so it can be turned off.

Database.SetInitializer<{class name}>(null);

 

相关文章:

  • 2021-08-26
  • 2021-12-15
  • 2021-10-25
  • 2021-07-21
  • 2021-11-24
  • 2021-08-18
猜你喜欢
  • 2021-05-23
  • 2022-02-25
  • 2022-02-18
  • 2021-08-31
  • 2021-09-07
  • 2021-10-12
  • 2021-11-23
相关资源
相似解决方案