Sql – Visual Studio and LINQ: placing the DBML file in separate directory in the project

dbmllinq-to-sqlvisual studio

My strategy was to keep the project's layout clean. Given that this is a datalayer project, and I'll have a class file for each concerned entity, I thought I would put the .dbml into its own directory. It turns out that locating your .dbml file within a subdirectory turns it into a lower level namespace of sorts.

This is a C# class library project.

Any hints where I could turn this functionality off, and get access to the LinqToSql dbml datacontext name without having to type the directory name to get access to the actual LinqToSql classes?

Best Answer

Turns out you need to find the properties of your DBML on the LinqToSql design canvas.

  • Right click -> Properties Find the Context Namespace.
  • Type in the namespace that you expect to have your DataContext classes available in.
  • Right below, find the Entity Namespace.
  • Do the same

Resharper Users: you have the option to view the properties of your DBML's subdirectory, and set the namespace attribute there.