sqlmetal

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 contains the DataContext class in C# that is used throughout the app (and is derived from the...

SQLmetal, is it only a mapper for linq to sql?

Hi, Is the code gen tool sqlmetal only a mapper to linq to sql? I'm looking for something that will create common CRUD operations also like: GetUserByID UpdateUserByID InsertUser GetAllUsers etc. ...

How to add a SqlMetal build step in VS2008?

I've created a one-line batch file to run SqlMetal to regenerate a LINQ to SQL DataContext for my database; this works great. *Refresh_DataContext.bat*: "C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sqlmetal.exe" /server:.\sqlexpress /database:MyDatabaseName /code:"%~dp0\DataContext.vb" /context:DataContext /vie...

Accessing members of the other half of a partial class

I'm just learning to work with partial classes in VB.NET and VS2008. Specifically, I'm trying to extend a LINQ to SQL class that was automatically created by SqlMetal. The automatically generated class looks like this: Partial Public Class DataContext Inherits System.Data.Linq.DataContext ... <Table(Name:="dbo.Concessions")> ...

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 itself as internal. Is there a way to do this in sqlmetal or some other tool without havin...

Run web app code from command line?

I have an ASP.NET web application that includes code for enforcing its own database schema ; this code runs on application start. I've recently started using LINQ to SQL, and I've added a pre-build event to run SqlMetal on my database so that I get objects representing my db tables. What would be really cool is if I could enforce the ...

Generating your LINQ-to-SQL datalayer

I usually use Codesmith & NetTiers for my datalayers, and as they can be run from the command line it just requires a simple batch file to regenerate / rebuild everything whenever changes are made to the database. Now I'm looking at LINQ-to-SQL, but I'm not finding the WYSIWYG entity designer as convienient. What other methods are avail...

SqlMetal generating garbage association names

Why is SqlMetal messing up the Association names. For e.g. in my 'TextMessage' table i have two columns referencing the 'ApplicationUser' table. 'SenderUserId' and 'RecipientUserId' When I run SqlMetal and look at my 'ApplicationUser' class For 'RecipientUserId' it generates: [Association(Name="FK__TextMessa__Recip__72910220", Storage...

How to create a LINQ To SQL datacontext for large DB using SQLMetal when it generates a 12MB DataContext.cs file?

My problem is this: We have a very large Legacy DB with many SPROCs, Views & Tables. The Designer is a "NO GO" b/c of the size. I've configured SQL Metal to build the data context, but the resulting code file is so big (12MB) visual studio 2008 will not open it. If SQLMetal would generate a new file for each class type (Table, View,...

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 data results. However, when select columns are included in the linq query, the results g...

SqlMetal scripting and capitalization

When I run SqlMetal it generates all views and functions with a capital letter. Is their a way to make it generate it in whatever case is in the database? When I use the UI to build the DBML and CS file it handles this properly, however when I script it SqlMetal seems to make them upper case. This isn't a huge deal however it makes me ...

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 table? I've tried running diffs against the files generated by SQLMetal with some limited succ...

Generating Linq classes from a SQL Compact 3.5 database using SQLMetal

I am generating Linq classes by running SQLMetal from the command line against a Compact 3.5 database. The Compact 3.5 database is a local database cache (generated by the Sync Framework "Create Local Database Cache wizard). CE seems to support foreign keys constraints, but I am not seeing any, and SQLMetal does not generate them into th...

Ignore Code Analysis for SqlMetal generated files

I'm developing a C# project which includes a SqlMetal generated file. I'd like to use Code Analysis. I've turned on "Suppress results from generated code" in the Code Analysis options, but it still reports on the SqlMetal classes. Is there some way to turn this off? I'm using Visual Studio 2008 and SqlMetal 2.0.50727.3082 ...

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, however it doesn't seem to work on this machine... Am i missing something? ...

Why is SQLMetal.exe generating different results for SQL Compact 3.5 and SQL Express 2008 (foreign keys are missing).

Here's the story: I created a SQL Compact 3.5 database and used SQLMetal.exe to generate DataContext for it. It worked well, but soon I realized that it simply does not suit my needs so I decided to go for SQL Express 2008. I fired up the very same SQL script I used for the Compact to create schema and then fired up SQLMetal.exe tool. I ...

MSLinqToSQLGenerator generates different output than SQLMetal

I have a rather large DBML file and recently discovered that Visual Studio's MSLinqToSQLGenerator is generating different output than: SqlMetal.exe All.dbml /code:All.designer.vb /namespace:LINQ2FSE /pluralize /provider:SQL2005 It seems to have dropped an arbitrary (and I think relatively small) set of associations from the generated ...

C#: Add data to an SQLMetal generated database class?

I used SQLMetal to generate a code file representing my database, and i can't figure out how to add entries to the database from the SQLMetal generated classes. How do i do this? do i just add to the various properties or something? ...

[Linq to SQL] 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 keys to the same table. Unfortunately, when these tables are pulled into a Linq model and th...

Generation custom files from dbml file?

Hi, I've been having a look at making changes to the partial classes generated from a DBML file. I was reading into using the sqlmetal.exe tool but it appears that you can't do much customisation of what it actually spits out. I'm wanting to make changes to the file for serialization purposes, I'd like to add the Data Member Attribute...