Updates to the data model
-
28. dubna 2012 18:55
I'm new to LINQ and have a major question. From what I've read it's difficult to update a LINQ to SQL class "project" (done by this method http://msdn.microsoft.com/en-us/library/bb384470.aspx) after the classes are created. I have definitely not solidified my data model in SQL Server yet, but I do want to be able to start developing my WPF application. Once I use the O/R Designer to drag tables from SQL Server Object Explorer onto the DBML page how would I go about updating the class when I add a column? Worse yet, what if I do something more complex like change a column name, add a foreign key, change the columns in a primary key, etc? I really like the idea of LINQ but I don't want to make extra trouble for myself.
Thanks!
Všechny reakce
-
30. dubna 2012 2:40Moderátor
Hi mateoc15,
Welcome to MSDN Forum.
Based on the issue, please refer to this article. I suggest you to use Entity Framework instead of LINQ to SQL. Entity Framework support migration, whenever you add, delete or modify the schema of the database, you can synchronize with the model by inputting few lines of command. More information about Entity Framework, please refer here. Migration in Entity Framework, please refer to the two links below.
EF 4.3 Code-Based Migrations Walkthrough
EF 4.3 Automatic Migrations Walkthrough
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
- Označen jako odpověď Allen Li - AI3Microsoft Contingent Staff, Moderator 7. května 2012 7:09
-
30. dubna 2012 13:03Thanks Allen. It seems like this is almost like a "dumbed down" data modeler like ER/Studio but with some .NET code generation features. I'll give it a shot. Thanks.
-
30. dubna 2012 17:01
In looking at some articles it doesn't seem that too many developers (including MVPs) have much good to say about Entity Framework. Can you convince me that it's right for my project (small scale, thick client client-based solution with local database instance)?
In my situation why do you advise against LINQ to SQL?
And does anyone know anything about this free API? http://www.perpetuumsoft.com/Product.aspx?lang=en&pid=55&tid=linqtosqlsynchronization- Upravený mateoc15 30. dubna 2012 17:12 Added Perpetuum stuff
-
1. května 2012 2:11Moderátor
Hi mateoc15,
LINQ to SQL only support SQL Server database, but Entity Framework supoort more databases. Furthermore, Entity Framework could complete all the works which LINQ to SQL could. More information about the difference between them, please refer to the links below.
Choosing between ADO.NET Entity Framework and LINQ to SQL
Choosing between LINQ to SQL and Entity Framework
Based on the initial post, you said you modified the schema of the database, and may modify again in the future. Entity Framework supports this feature after EF4.3 releasing, more information about it, please refer here. So I suggest you to use Entity Framework.
Best Regards
Allen Li [MSFT]
MSDN Community Support | Feedback to us
- Označen jako odpověď Allen Li - AI3Microsoft Contingent Staff, Moderator 7. května 2012 7:09
-
1. května 2012 12:23Thanks Allen.
-
9. května 2012 1:58Přispěvatel
Hi,
I have an add-in that adds full incremental sync to the L2S designer (and the EF designer too). You can download it and get a trial license from http://www.huagati.com/dbmltools/ if you want to try it out.

Cool tools for Linq-to-SQL and Entity Framework 4:
huagati.com/dbmltools - Visual Studio add-in with loads of new features for the Entity Framework and Linq-to-SQL designers
huagati.com/L2SProfiler - Runtime SQL query profiler for Linq-to-SQL and Entity Framework v4