Changing the return type of a DataContext method cannot be undone

Note

This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Changing the return type of a DataContext method cannot be undone. To revert back to the automatically generated type, you must drag the item from Server Explorer/Database Explorer onto the O/R Designer again. Are you sure you want to change the return type?

The return type of a DataContext method differs depending on where you drop the item in the O/R Designer. If you drop an item directly onto an existing entity class, a DataContext method that has the return type of the entity class is created. If you drop an item onto an empty area of the O/R Designer, a DataContext method that returns an automatically generated type is created. You can change the return type of a DataContext method after you add it to the methods pane. To inspect or change the return type of a DataContext method, select it and click the Return Type property in the Properties window.

To change the return type of a DataContext

  • Click Yes.

To exit the message box and leave the return type unchanged

  • Click No.

To revert to the original return type after changing the return type

  1. Select the DataContext method on the O/R Designer and delete it.

  2. Locate the item in Server Explorer/Database Explorer and drag it onto the O/R Designer.

    A DataContext method is created with the original default return type.

See Also

LINQ to SQL Tools in Visual Studio DataContext Methods (O/R Designer) How to: Create DataContext methods mapped to stored procedures and functions (O/R Designer) LINQ to SQL