Solved

Update Linq .dbml schema in VS2008

Posted on 2008-10-09
3
3,852 Views
Last Modified: 2013-11-11
Hello,
I am trying to update the Linq schema within VS2008 - when I make changes to the underlying Sql database. I have tried using SqlMetal but if I replace the existing .dbml file in my project with the SqlMetal .dbml file I get an error pointing to the layout file. If I delete the layout file, I am then able to open the new .dbml in VS file but there is no longer a valid datacontext - there all code that was depending on this Linq datacontext fails regardless if I rebuild the solution.

Here is the current SqlMetal command line (which seems to work fine?):
sqlmetal.exe /conn:"server='itsa1'; database='myinsbusiness'; user='admin'; password='password'" /dbml:"C:\Program Files\MyInsBusinessFetch\SqlData\MyInsBusiness_LinqDB.dbml" /sprocs /views

So my question is how do rebuild my .dbml to use within VS2008?
0
Comment
Question by:jherington
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 21

Accepted Solution

by:
naspinski earned 500 total points
ID: 22684210
You can use SQLMetal.exe to generate your dbml and or cs/vb file. Use a pre-build script to start it and target the directory where your datacontext project belongs.

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64\sqlmetal.exe
  /server:<SERVER>
  /database:<database>
  /code:"path\Solution\DataContextProject\dbContext.cs"
  /language:csharp
  /namespace:<your namespace>

I stole it from here: http://stackoverflow.com/questions/40022/best-way-to-update-linq-to-sql-classes-after-database-schema-change#40034
0
 

Author Closing Comment

by:jherington
ID: 31504745
Thank you. The link lead me to several other links that should prove to be very helpful. I am still somewhat confused...would the dbContext.cs file in your example in effect replace the dbml, layout and designer files?
0
 
LVL 16

Expert Comment

by:Ady Foot
ID: 26161848
Can anyone help me further with this?  I'm unsure how to use the sqlmetal application as naspinski has shown.  I too tried to use it as jherington and experienced the same result.

Regards,

Ady
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Error import assembly 19 30
connection to SQL 2012 error in windows 10 18 49
semaphore timeout period has expired 1 32
SQL Server Pivot 5 42
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question