p.campbell
p.campbell

Reputation: 100607

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

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?

Upvotes: 5

Views: 4218

Answers (2)

p.campbell
p.campbell

Reputation: 100607

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.

Upvotes: 10

CodeLikeBeaker
CodeLikeBeaker

Reputation: 21312

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.

Upvotes: 3

Related Questions