Search code examples
c#linqlinq-to-sqlsqlmetal

SQLMetal: How to find Connection String?


I am trying to create a simple offline application for personal-use that uses a SQL Server Compact 3.5 database and I plan to use Linq-to-SQL to work with it. I have used SQLMetal (through the application SqlmetalBuilder) to create a dbml file, and have added it to my project.

The problem I am having is that, unlike the O/P Designer (which you cannot use on SQL Server Compact files), SQLMetal creates code that requires me to enter the connection string when instantiating a DataContext.

How do I find out what the connection string is? I have looked but I can't find the answer... And if there is a way to create the code so that I don't have to enter the connection string (this app is not to be distributed), any advice would be appreciated.


Solution

  • SqlMetal.exe (Code Generation Tool)

    See Connection Options: /conn: connection string.

    Update:

    SQL Server Compact 3.5 and Visual Studio (look for connection string).

    You can pass the connection string to the constructor of DataContext class.