The SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3 is available for download at Microsoft Download Center.
To install SQL Server Compact 3.5 SP1 Beta Release for ADO.NET Entity Framework Beta 3
- Install ADO.NET Entity Framework Beta 3 from Microsoft Download Center. You must ensure that the pre-requisites specified on the download page are installed before installing ADO.NET Entity Framework Beta 3.
- In Control Panel, double-click Add or Remove Programs. Uninstall SQL Server Compact 3.5 or SQL Server Compact 3.5 SP1 Beta.
- Install SQL Server Compact 3.5 SP1 Beta Release for the ADO.NET Entity Framework Beta 3 (SSCERuntime-ENU.msi) from the Microsoft Download Center. Note that administrator rights are required on a computer to install SQL Server Compact 3.5 SP1 Beta Release for ADO.NET Entity Framework Beta 3.
To install ADO.NET Entity Framework Tools December 07 Community Technology Preview (CTP)
- Install the ADO.NET Entity Framework Beta 3 and SQL Server Compact 3.5 SP1 Beta Release for the ADO.Net Entity Framework Beta 3 as specified above. Install ADO.NET Entity Framework Tools December 2007 CTP from the Microsoft Download Center. You must ensure that the pre-requisites specified on the download page are installed before installing ADO.NET Entity Framework Tools December 2007 CTP. The CTP installs on a Visual Studio 2008 installation.
- Copy the SQL Server Compact 3.5 SP1 Design Tools Beta (SSCEVSTools-ENU.exe) to your computer by clicking on Save or Save this program to disk and after the download is complete install SSCEVSTools-ENU.exe by double-clicking it. Do not install the SSCEVSTools-ENU.exe by clicking on the Run. While running the SSCEVSTools-ENU.exe file, Microsoft.SqlServerCe.Client.dll is extracted to %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE folder. The SSCEVSTools-ENU.exe will create a backup of the existing DLL at the location %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE.
For uninstalling SQL Server Compact 3.5 SP1 Beta refer to the read me.
The steps to create a sample application are as given below:
1. Start Visual Studio 2008 and create a console project by clicking on the menu item File à New à Project. In the New Project window expand Visual Basic or Visual C#, select Windows and then select Console Application. For the project the .Net Framework version should be .Net Framework 3.5. Name the project as SQLCompactEDMProject. On clicking OK the project is created
2. To generate the Entity Data Model for the Northwind.sdf, copy the Northwind.sdf from the folder %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Samples to the users folder like C:\Users\<login name>\Documents\Visual Studio 2008\Projects\SQLCompactEDMProject\SQLCompactEDMProject. Select the SQLCompactEDMProject in the Solution Explorer and right-click, point to Add, and then click New Item. Select ADO.NET Entity Data Model in the Templates pane. Enter Northwind.edmx for the model name and click Add. The opening page of the Entity Data Model Wizard is displayed.
3. Select Generate from database in the Choose Model Contents dialog box and click Next. Click the New Connection button. The Connection Properties dialog box is displayed.
4. In the Connection Properties dialog click the button Change in the Data Source. In the Change Data Source dialog box select Microsoft SQL Server Compact 3.5 and click OK. Click the radio button My Computer in the Data Source. In the Connection Properties browse to the Northwind.sdf and click OK in the Connection Properties dialog. The Choose Your Data Connection screen in the Entity Data Model Wizard comes up.
5. The checkbox in front of Save entity connection settings in App.Config as: will be clicked by default. Change the name in the dialog from Entities to NorthwindEntities. Click Next to continue.
6. The Choose Your Database Objects dialog box is displayed. By default all the tables in the database are selected and will be included in the EDM. Uncheck the box next to Tables. This deselects all the tables in the database. Expand the Tables node and select the Customers, Orders, and Products tables. Change the Model Namespace: from Model to NorthwindModel
7. Click Finish to complete the wizard.
a. The wizard does the following:
b. Adds references to the System.Data, System.Data.Entity, System.Core, System.Security, and System.Runtime.Serialization assemblies.
c. Generates an .edmx file which encapsulates the information from the EDM mapping files.
d. Creates an App.Config file.
8. Double click the App.Config file in the Solution Explorer to open it. Change the provider entry from provider=Microsoft.SqlServerCe.Client.3.5 to provider=System.Data.SqlServerCe.3.5
9. Add an Imports (Visual Basic) or using (C#) statement at the beginning of the file to reference the EDM created from the Northwind database. (The name of the model corresponds to the value of the namespace attribute in your .edmx file).
10. Add the following code to the Main subroutine (Module1.vb or Program.cs)
Using db As NorthwindEntities = New NorthwindEntities
Dim customers = From c In db.Customers _
Where c.City = “London” _
Order By c.Company_Name Select c
For Each c As Customers In customers
using (NorthwindEntities db = new NorthwindEntities())
var customers = from c in db.Customers
where c.City == “London”
foreach (Customers c in customers)
11. Press CTRL+F5 to run the application. After the results display on the console screen press enter to exit the application
Program Manager – SQL Server Compact