A have an app with that uses an SQL database. The application is already released, but now I'm working on an update. In the update I've added an extra column in a table of my database.
I've create the database from my DMBL using DataContext.CreateDatabase() (not the other way around, as I found out to be the more common scenario later)
I there a facility in LINQ in which I can update my SQL database scheme?
DBML (Database Markup Language) is an open-source DSL language designed to define and document database schemas and structures. It is designed to be simple, consistent and highly-readable.
Open the LINQ to SQL file in the designer. (Double-click the . dbml file in Solution Explorer.) In Server Explorer or Database Explorer, expand Stored Procedures and locate the stored procedures that you want to use for the Insert, Update, and/or Delete commands of the entity class.
In Visual Studio, right click on your project in the Solution Explorer, on the folder where you want to add the DBML. Choose Add New Item, then under Data, choose Linq-To-SQL Classes . This will create an empty DBML file.
No, sorry. I also would like to have such a facility. You have to upgrade your database by hand.
Here's the Method:
Hint: After the initial release I never change my database schema with an tool. I always script that change and put that in my next update script.
Not that what you've asked, but it's a practicable solution.
An UpdateScript may look like this:
** PSEUDOCODE**
-- Update to version 2
alter table [MyTable] add newColumn int null
GO
update [MyTable] set [newColumn] = 0
GO
alter table [MyTable] change newColumn int not null
GO
alter procedure spGetDBVersion
as
begin
select 2 as CurrentVersion
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With