If you are keeping your DataContext separate from your working project, then you need to add the connection strings to the database from the DataContext project to the working project's config file as well for it to work.

网友答案:

You can also pass in the connection string to the DataContext constructor as follows: