Questions tagged [sqlmetal]

The SqlMetal command-line tool generates code and mapping for the LINQ to SQL component of the .NET Framework.

The SqlMetal command-line tool generates code and mapping for the LINQ to SQL component of the .NET Framework.

93 questions
17
votes
5 answers

Linq to SQL - Don't fetch a particular column

Is there a way to not fetch a specific column using linqtosql without having to use an anonymous type and specify each returned filed individually? We use SQLMetal to generate the dbml file which contains all the types into which to put the queried…
James
  • 7,877
  • 7
  • 42
  • 57
11
votes
3 answers

sqlmetal.exe not found

Whenever i try to run sqlmetal, i get this: 'sqlmetal' is not recognized as an internal or external command, operable program or batch file this is from both CMD and the Visual Studio Command Prompt I've used sql metal many times on other machines,…
Alex
  • 37,502
  • 51
  • 204
  • 332
7
votes
4 answers

SQLMetal Multiple Foreign Keys Pointing to One Table Issue

Edit - Cleaning up question to better reflect the actual issue: I'm using SQLMetal to generate database classes from our SQL Server db. Recently, I needed to add a table that had multiple foreign keys pointing to the same table. Using LINQPad to…
Ocelot20
  • 10,510
  • 11
  • 55
  • 96
7
votes
4 answers

Multiple foreign keys to the same table

I have a reference table with all sorts of controlled value lookup data for gender, address type, contact type, etc. Many tables have multiple foreign keys to this reference table I also have many-to-many association tables that have two foreign…
cdonner
  • 37,019
  • 22
  • 105
  • 153
6
votes
3 answers

SQLMetal generates classes but not parameterless constructors

I need to regularly refresh my Linq To SQL classes; Yes, shame on me for not thinking about my data schema thoroughly enough, bad developer, ad nauseum. I found SQLMetal almost does the trick, but maybe I'm missing something from the parameter…
David Fox
  • 10,603
  • 9
  • 50
  • 80
6
votes
3 answers

How do I update a foreign key efficiently in LINQ to SQL/SQLMetal?

I ran into an issue trying to update a foreign key field: record.ForeignId = newId; It bombs with "Operation is not valid due to the current state of the object" due to SQLMetal code that throws…
Scott Stafford
  • 43,764
  • 28
  • 129
  • 177
6
votes
1 answer

SqlMetal wrongly generates the return type of my stored proc (LINQ)

Hi have a stored proc that always returns a single row depending of a parameter: IF @bleh = 1 SELECT TOP 1 Xyz FROM Abc ELSE SELECT TOP 1 Def FROM Abc I must use SqlMetal to generate the DataContext but this stored procedure returns a…
6
votes
1 answer

how to force sqlmetal to keep field name case?

When dbml file is generated automatically by Visual Studio I get the exact field names as they appeared in the tables. However, since VS does not provide refresh function for dbml, I run sqlmetal manually to re-create dbml file. It works fine with…
greenoldman
  • 16,895
  • 26
  • 119
  • 185
5
votes
1 answer

Using enums in Visual Studio 2010 Table Designer

I'm designing a data base using the Table Designer in VS 2010 pro, then generating code with SqlMetal. I want to use a enum as a type in one of the columns. How is it possible?
elyashiv
  • 3,623
  • 2
  • 29
  • 52
5
votes
2 answers

Autogeneration of a DataContext designer file when using SqlMetal and Visual Studio

I am using SqlMetal to general my DataContext.dbml class for my ASP.net application using LinqToSql. When I initially created the DataContext.dbml file, Visual Studio used this to create a related DataContext.designer.cs file. This designer file…
Yaakov Ellis
  • 40,752
  • 27
  • 129
  • 174
4
votes
3 answers

Is it possible to auto-generate my Linq2Sql DBML via a script?

I use Linq2Sql and am tired of recreating the dbml everytime the database changes. Is it possible to script the creation of my model given that I want ALL tables and ALL procs? Ideally it would be part of the build process or a custom tool. A…
TheSoftwareJedi
  • 34,421
  • 21
  • 109
  • 151
4
votes
2 answers

How do I use sqlmetal to generate an internal (not public) data context

I'd like to use sqlmetal to generate dbml data contexts for my project, but the data context and all classes created are marked as public. As this is supposed to be an API layer I'd like to instead mark many of these classes or at least the context…
Mykroft
  • 13,077
  • 13
  • 44
  • 72
4
votes
3 answers

SQL Metal for specific tables or another way to refresh/add table to .dbml file

anybody have any easy way of doing this in Visual Studio, without having to use the Server Explorer ? I tried also looking at macro's but recording only produce Sub TemporaryMacro() End Sub So no luck there. Any way to script this?
hreinn1000
  • 255
  • 1
  • 7
  • 18
4
votes
1 answer

SQL metal to dbml, how to generate correct foreign key column names

I have this 2 tables table name: Person with Columns:PersonID, Name table name: VisitInfo with Columns: VisitPersonID , CoordinatorPersonID both columns have a foreign key to person table When i generate the code i get a VisitInfo class with the…
MichaelD
  • 8,377
  • 10
  • 42
  • 47
3
votes
2 answers

When I make a database change, how do I know what needs to be removed and readded to the LinqToSql O/R Designer in Visual Studio?

For example, I alter a column in a table to be not null from null. I need to then delete and readd the table. That part is pretty clear. What about views, functions, and stored procedures that access the table, especially that column in the…
Michael Maddox
  • 12,331
  • 5
  • 38
  • 40
1
2 3 4 5 6 7