By default, you cannot use a dbml model for a SQL Server CE database.
Still, the model can be created by using the application SqlMetal.
The application can be found in the directory (supposing that you have Windows installed on the C: partition).
[Windows x64] C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin
[Windows x86] C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin
1)Open Command Prompt (Start->Run->enter cmd in textbox).
2)Once the console (Command Prompt) is opened, write:
SqlMetal /dbml:Database.dbml Database.sdf
Database.dbml must be replaced with the path to the location where you want to generate the dbml model.
Database.sdf must be replaced with the path to the location of the database (the sdf file).
3)The generated file will contain the database map (the database model). To use the model in Visual Studio, you must attach it to your current project.
You can also create a DataContext using gui tools with my SQL Server Compact Toolbox add-in
ReplyDelete