Solved

Update Linq .dbml schema in VS2008

Posted on 2008-10-09
3
3,847 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

762 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

12 Experts available now in Live!

Get 1:1 Help Now