Model-First Approach
Follow the procedure below to use the Entity Data Model Wizard to create the .edmx file and execute queries.
Install and Set Up Entity Framework
Install Entity Framework or add references to the required assemblies for your chosen version of Entity Framework. The assemblies are located in the lib subfolder of the installation directory. See Using EF 6 for using Entity Framework 6. See Installed Assemblies for more information about all assemblies shipped with the provider
Add a New Item To Your Project
In the Visual Studio Solution Explorer, right-click your project and click Add -> New Item.
Create an ADO.NET Entity Data Model
In the resulting Add New Item dialog, click ADO.NET Entity Data Model and name it an appropriate title, such as "NetSuiteEntityDataModel.edmx".
Follow the Entity Data Model Wizard
Create the .edmx file with the Entity Data Model Wizard:
- On the first page, select Generate from database.
- On the next
page, select the data provider connection you intend to use with
your project or create a new connection.
Set the CacheLocation and CacheMetadata connection properties to cache table metadata - this is necessary to make generating the Entity Framework model more efficient. To learn about this process, see Caching Metadata.
- Select whether to include sensitive data (such as passwords) in the connection string. Note that the option to exclude sensitive data means password fields will not be copied to the generated config file with the rest of the connection string properties.
- Check the box to save the entity connection settings in App.Config, and enter a name for the context class of the data connection; for example, "NetSuiteEntities".
- After Visual Studio retrieves the necessary information from the live data source, the wizard presents a listing of database objects you can include in your project. Note that this step may take several minutes as Visual Studio retrieves table schemas from NetSuite.
Perform LINQ Commands in Your Code
You are now ready to start using LINQ in your code.
NetSuiteEntities context = new NetSuiteEntities();
var AccountQuery = from Account in context.Account
orderby Account.AcctName
select Account;
Note: Be sure to declare "using System.Linq" in your file.