dbml

Linq To SQL vs Entity Framework Connection Strings

Thanks for taking a look at my post. I've been working with linq to sql and have generally been happy, until i just noticed that database table names are hardcoded into the classes/dbml files-- which can't work in our environment. We need to be able to have database names completely changeable via web.config-- in one place. That's a def...

How to reference the SQL column description field through the DBML?

I would like the SQL column description property to hold the friendly name of the column to display to the users. Is there a way that I can reference this column property through the DBML? Update: We ended up writing a c# method that injects a space into a camel case string and renaming the DB columns to be more friendly. ...

How can I switch between 2 Connection Strings in my Web.Config (Activate one for DBML)

Hello! I have two connection strings (both in Web.Config: CS_Local and CS_Production) for my DBML (Linq to SQL). In my Global.Asax/Application_Start I run some production preparation methods if the request is non-local (!HttpContext.Current.Request.IsLocal). Within that part, I'd also like to change the current connection string used b...

Sharing LINQ-to-SQL classes/models between multiple projects in a solution

I have multiple C# projects in a Visual Studio solution right now that will all use the same SQL Server database. What is the proper way to share LINQ-to-SQL classes between projects? I'm considering just copying the dmbl files into each project, but I think that may be too redundant. Is there a better way to approach this? ...

Sync LINQ-to-SQL DBML schema with SQL Server database

After creating a SQL Server 2008 database, I made a Linq-to-SQL schema in Visual Studio. Next, in the .dbml visual editor (in Visual Studio 2010), I added PK-to-FK and PK-to-PK associations to the schema. How do I copy those associations that I created in Visual Studio over to the database? In other words, how do I sync with the DB? ...

Missing tables on Scaffold Dynamic Data page

I created a Linq-to-SQL DBML for the first time. I dragged and dropped all my tables over to the designer. The tables all appear in the designer.cs file. In Global.asax, I also have model.RegisterContext() with the ScaffoldAllTables = true option. The routes are also setup. I can pull up the Scaffolding page, but there's at least on...

Nullable One To One Relationships with Integer Keys in LINQ-to-SQL

I have two objects (Foo and Bar) that have a one-to-zero-or-one relationship between them. So, Foo has a nullable foreign key reference to Bar.ID and a (nullbusted) unique index to enforce the "1" side. Bar.ID is an int, and so Foo.BarID is a nullable int. The problem occurs in the LINQ-to-SQL DBML mapping of .NET types to SQL datatypes...

SQLMetal DataContext Associations Not Generated

I am generating the LINQ-to-SQL DataContext and entity classes for a database. The database has several tables, two of which are - [AccountMaster] and [AccountCodes]. There is a foreign key relationship defined between them, with [AccountMaster].AccountNumber being referenced from [AccountCodes]. Adding a LINQ-to-SQL file in VS2008 and ...

LINQ Foreign Key Relationship Naming (Address, Address1, Address2)

Hello, is it possible to change the foreign key relationship object naming of LINQ to SQL generated objects? For example, I have a Demo table which has the fields ItemMinId, ItemMaxId, ItemExlId which are all foreign key references to my Item table. LINQ generates now Demo.Item, Demo.Item2, Demo.Item3 fields which makes it difficult in...

Override Attribute in Partial Class (DBML)

Hi, Is it possible to override an attibute set on a partial class? So I have one autogenerated partial class like this: [Table(Name="dbo.Users")] public partial class MbsUser : INotifyPropertyChanging, INotifyPropertyChanged { This is generated in my DBML. The problem is, I don't want my class to use this table. I've cr...

How to persist a change in a DBML

I have a table of users called Users And a view called UsersActive that filters out deactivated users. When I create my DBML, I drag the Users table in, then I change the property on the table to point to UsersActive. This works well, until the DBML gets re-created. Does anyone know how to fix this? I've tried overriding the [Tabl...

SQL Server timeout exception when extending Linq partial methods

In .NET 4.0 and Linq to SQL, I am trying to use a partial class to "trigger" changes from within an update method (an existing DBML method). For simplicity, imagine a table Things with columns Id and Value The auto gen DBML contains a method OnValueChanged, I'll extend that and as an exercise try to change one value in one other row : ...

Can I save a DMBL layout as a jpeg/png?

Hello, Is it possible to save the layout diagram from a DBML file as a jpeg/png or any other image format? A manager wants to know what we are storing in our database and the print out wasn't enough he wants an electronic version. I know I can use a screen-shot but wonder if there are any other options? I've just thought about printin...

LINQ To SQL: simpest way to rebuild dbml file

What is the easiest way to rebuild a dbml file with Visual Studio 2008? There is no "refresh" option in popup menu as in the Entity Framework wizard. I use bat file (that executes sqlmetal) from the project nowadays. ...

DBML: s letter added to my table names

I'm using Visual Studio 2008 Each time I modify my dbml through the designer some of the table names in the designer.cs file are changed from TableName to TableNames leading to some reference errors in the rest of the project. The names that appear on the dbml are not changed. Where does this come from ? Is it a setting ? Edit: It ha...

Setting Connection string in dbml files using Linq to SQL in Visual Studio 2008

I have an application that works with a database "TestDB". At the time I was developing the application I was using linq to sql and adding my data tables by dragging and dropping to the TestDB.dbml file and probably .net automatically sets the connection string to the local sql server on my machine. The application is supposed to launch ...

Linq dbml interchangeable between SQL Editions

I have a Desktop application that uses Linq To SQL as the DAL. It accesses a local SQL Express DB. If I have a SQL CE DB that has the Exact same schema(table structure) can I re-use the generated dbml with just giving it a different connection string? ...

Generated DBML code incorrectly marks returned columns as NOT NULL for stored procedures

I have a stored procedure in SQL Server that returns some data via a select: CREATE PROCEDURE spDDIs_Get(@ID INT) AS IF NOT EXISTS (SELECT ID FROM tDDIs WHERE ID = @ID) RAISERROR('ICT0005:DDI does not exist', 18, 1) ELSE SELECT D.ID, D.SchemeID, C.ID ConfigurationID, C.Description Configuration, D.RecordCall, D.DDIN...

Generate a Database using LinQ to SQL DBML file

I just inherited a project with LinQ to SQL Database file. I need about half of the 100 plus database tables so I would like to Generate a database based off the DBML file and strip out the stuff I dont need. Is there a way to do this? ...

Linq related table not queryable error

Hi all, I've got a problem with Linq in VB.NET. I've created a .dbml file from my db, and everything looks good - relation "arrows" between tables are visible, etc. But when I want to use simple query (taken from 101 Linq Samples by MS): Dim q = From h In dc.Hours, w In h.WorkType I receive an error: Expression of type 'INTegrit...