views:

890

answers:

2

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?

+3  A: 

If you go to the directory in your solution and view the properties of that directory you will see the attribute: Namespace provider = true

Set this to false

You can then go update the namespace to match the root namespace in your DBML file. Now whenever you add new dbml files in there, it will keep the namespace based on the root folder.

Jason Heine
Hmmm.... where would I see this attribute? When I click on a subfolder in my class library project, all I see in the "Properties" window is "Folder Name". VS 2008 SP1
marc_s
Interesting, i am using VS 2008 SP1 and I have Folder Name and Namespace Provider... I do have resharper installed, I wonder if that added it...
Jason Heine
+4  A: 

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.

p.campbell