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?
To create a DBML file, right-click on your project à Go to Add à select New Item à select LINQ to SQL template, give name as “ EmployeeDB ” and click like as shown below.
To create a DBML file, right-click on your project à Go to Add à select New Item à select LINQ to SQL template, give name as “ EmployeeDB ” and click like as shown below. After adding LINQ to SQL dbml file, that will be as shown below. Here if you observe, we have two sections in the left side section.
Now we finished creating a new project. To use LINQ to SQL in our application, we need to create a “ DBML ” file, and the DBML file will contain source code that will allow us to write LINQ queries to get data from the SQL database.
Open the O/R designer. To add a LINQ to SQL entity model to your project, choose Project > Add New Item, and then select LINQ to SQL Classes from the list of project items: Visual Studio creates a .dbml file and adds it to your solution. This is the XML mapping file and its related code files.
Turns out you need to find the properties of your DBML on the LinqToSql design canvas.
Resharper Users: you have the option to view the properties of your DBML's subdirectory, and set the namespace attribute there.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With