简体   繁体   中英

LINQ to SQL doesn't exist in my visual studio 2012

I am learning about how to add a data access layer to my project.

I found this tutorial http://msdn.microsoft.com/en-us/library/bb470374.ASPX :

  1. Right-click the App_Code folder and then click Add New Item. The Add New Item dialog box is displayed.

  2. Under Visual Studio installed templates, select the LINQ to SQL Classes template and rename the file Tasks.dbml.

  3. Click Add.

but when I right click I see this:

在此处输入图片说明

there is no Visual Studio installed templates nor LINQ to SQL Classes

Under VS2102, in your solution explorer, right click on your project, and select "Add/New Element" (something like this, my VS version is in french..)

Then you might find : C# -> Data -> "Linq to Sql classes" (depending on your Visual studio version i guess) or you can select "Entity Data Model", An assistant should appear to guide you through the rest of the process.

In your project classes you should then use your dataModel, and use Linq to make your requests.

I don't have everything in mind right now, you should check that tutorial : http://msdn.microsoft.com/en-US/en-en/library/vstudio/bb399182(v=vs.100).aspx

Hint: the generated model has a partial class for all your table fields, this is usefull for creating another class of the same name to add specific functions, or fields ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM