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
To install ADO.NET Entity Framework Tools December 07 Community Technology Preview (CTP)
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).
Visual Basic
Imports SQLCompactEDMProject.NorthwindModel
C#
using NorthwindModel;
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
Console.WriteLine(c.Company_Name)
Next
Console.ReadLine
End Using
using (NorthwindEntities db = new NorthwindEntities())
{
var customers = from c in db.Customers
where c.City == "London"
orderby c.Company_Name
select c;
foreach (Customers c in customers)
Console.WriteLine(c.Company_Name);
}
Console.ReadLine ();
11. Press CTRL+F5 to run the application. After the results display on the console screen press enter to exit the application
For more information and samples please see the ADO.NET Entity Framework Beta 3 Documentation and ADO.NET Entity Framework Samples
Regards,
Ambrish Mishra
Program Manager - SQL Server Compact