当前位置: 代码迷 >> .NET Framework >> Part 三 using entity framework
  详细解决方案

Part 三 using entity framework

热度:250   发布时间:2016-05-01 23:20:26.0
Part 3 using entity framework

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)l

 

  相关解决方案