Solved

Update Linq .dbml schema in VS2008

Posted on 2008-10-09
3
3,848 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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

912 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now