Development Environment
1. vs2010sp1
2. Microsoft SQL Server compact 4.0
3. Visual Studio 2010 SP1 tools for SQL Server compact 4.0 came out only after SQL Server compact 4.0 was vs10.
Create an SQL Server compact database
1. Use SQL Studio
The database file drop-down box displays the options for creating a compact database.
2. vs Studio
Vs new project added new data compact 4.0 database items
How to upgrade SQL compact 3.5 to SQL compact4.0
Use the upgrade () method
VaR filename = @ "G: \ XXX. SDF ";
VaR SSC = new system. Data. sqlserverce. sqlceengine ("Data Source =" + filename );
SSC. Upgrade ();
You must reference system. Data. sqlserverce. dll in the private folder of the installation path of SQL compact4.0.
Connect Entity Framework to SQL compact4.0
Entity Framework 4.0 or later is required
Connection string
<Connectionstrings>
<Add name = "XXX" connectionstring = "Data Source = data/xxx. SDF; persist Security info = false;" providername = "system. Data. sqlserverce.4.0"/>
</Connectionstrings>
Add provider Configuration
<System. Data>
<Dbproviderfactories>
<Remove invariant = "system. Data. sqlserverce.4.0"/>
<Add name = "Microsoft SQL Server compact data provider 4.0" invariant = "system. data. sqlserverce.4.0 "Description = ". NET framework data provider for Microsoft SQL Server compact "type =" system. data. sqlserverce. sqlceproviderfactory, system. data. sqlserverce, version = 4.0.0.0, culture = neutral, publickeytoken = 89845dcd8080cc91 "/>
</Dbproviderfactories>
</System. Data>
If you encounter some errors when you are not familiar with SQL compact deployment, refer to Uncle Qum's Microsoft ASP. NET site deployment guide (12): troubleshooting article
The correct configuration of SQL compact is as follows:
Copy the following files to the bin directory.
1. system. Data. sqlserverce. dll and system. Data. sqlserverce. dll under the desktop directory in v4.0
2. In v4.0, all files under x86 in the private directory or all files under amd64 correspond to 32-bit systems. amd64 corresponds to 64-bit systems.
Database provider accessed by system. Data. sqlserverce. dll. NET Compact framework. System. Data. sqlserverce. entity. dll supports ADO. NET Entity Framework.
For other DLL meanings, refer to the DLL file introduction of SQL Server compact.