Is there a better tool to manage LINQ2SQL DataContext files? - linq-to-sql

I have a rather large LINQ2SQL for a project that I am working on. I must confess that I primarily use the WYSIWYG editor provided by Visual Studio to manage and build the structure. I am starting to run into a problem when it comes to locating entities on the diagram and just working with it in general.
Is there a better WYSIWYG tool -- better than the one provided by Visual Studio -- out there that can assist in the management of the LINQ2SQL dbml file?

I don't know of any alternatives unfortunately for the linq2sql designer.
EDIT:
Further thought on this since comments....
While not a WYSIWYG you could look into SQL Metal (cmd line) to generate/work with the linq2sql generated files.
It does have an open source UI for it now also.
Check out http://csainty.blogspot.com/2008/02/linq-to-sql-sqlmetalexe.html for some info on it.

If you're using the WYSIWYG tool just to build database structures, you might want to move over to using the "Entity Framework" and use some other tool to design the database structure.

You need to give some serious thought to how you are approaching this problem. There may be commercial products out there that meet your needs, but there isn't anything freely available that comes even close. I haven't seen any clear reviews of commercial tools in this regard.
The Linq2Sql O/R Designer doesn't scale, as you've unfortunately found out the hard way. Something like SQLMetal will scale much better, but it's not a perfect solution either.
Unfortunately, it can be very painful to switch from using the O/R Designer to SQLMetal as they don't share as much code underneath the covers as you would hope.
If you are trying to use a large database with Linq2Sql, you almost have to find and adopt a commercial tool of some sort. One free option worth considering is Damien Guard's LinqToSql T4 Templates, but it's not even close to a WYSIWYG tool.
Switching to a more capable ORM is also going to be difficult.
I wrote a blog entry on this subject some time ago and I've rehashed a lot of this already in this answer:
Do not use the Visual Studio 2008 LinqToSql O/R Designer
Good luck.

Check out my add-in at http://www.huagati.com/dbmltools/
It does not replace the designer, but it adds a pile of missing functionality to the designer, so it makes the designer easier to use.

Related

Simplest way to add XML doc to a WinRT project

We have a group of developers moving from C++ to C# and WinRT. We used D'Oxygen as part of our C++ developer builds, and I'd like to continue to have document generation as part of the developer build in C#/WinRT.
It's easy to turn on XML Doc generation, and I believe that will provide warnings for malformed tags, but without actual HTML output, I think our developers will be missing valuable feedback.
Looks like NDoc is now defunct, and I took a quick look at Sandcastle, but found it rather complex. Ideally, I'm looking for something that doesn't unduly burden developers, or require them to remember extra steps as they edit, build, test, and commit. In other words, the best solution would be something that "just happens", like a post-build step, and doesn't add significantly to each developer's build time.
If anyone has had some experience doing this in C#/WinRT, I'd sure like some advice.
Thanks in advance!
Get Sandcastle Help File Builder.
Create a help project for your library in the Visual Studio solution.
Remove Build check mark from Debug solution configuration to build the documentation project only in Release configurations, since Debug is most often used during development. For release build testing or performance testing you can either create another solution configuration or simply switch the option back and forth.
Build the documentation once
Include the documentation file in the solution so it shows up in the Pending Changes window when the file changes.
Kindly ask your developers to build with the release configuration that updates the documentation before check-in or use any other policy to require updating the documentation.
I don't think it makes sense to build the documentation all the time, but it helps to make it easy to do so that when you actually need an updated version - you can build it really quickly.
You can also make sure to use FXCop or StyleCop (forgot which) and configure it to treat missing XML documentation warnings as errors - at least in release builds. Doing it for debug configurations might slow down development and make changes difficult since developers often want to try things out before committing to a final implementation worth documenting.
EDIT*
Sandcastle provides various output formats as shown in the project properties:
I would like to mention ForgeDoc (of which I'm the developer), it could be what you are looking for. It is designed to be fast and simple, and it generates proper MSDN-like HTML output. It also has a command-line interface so you can just call it from a post-build event command in Visual Studio.
I think you should give it a try, as I would really like to hear about your thoughts.

Upshot helper extension using Linq To Sql

This is my first question on SO, so please bear with any mistakes/irregularities.
I wanted to implement SPA for my new project, Hence I reached Steve Sandersion's after some googling blog.
Looking at the code hosted on github, I noticed that I had to use EF to use Upshot, but my DAL is already written in Linq to Sql, which will be very tiresome to migrate to EF.
So my questions are as below
Has anyone successfully used upshot with L2S? If yes some example would help.
Is there any other way to implement the SPA without upshot so that I can reuse my DAL in L2S?
Edited
I just found today that this question stands useless, as using upshot will not be feasible. Microsoft has stopped working on Upshot.Some one please close this question.
I don't think it is possible. Microsoft has made it sure that people using Linq-to-sql don't survive.
Better use something like jquery and web api with some js mvvm libraries.
As far as I know this should be possible. When using upshot you don't need to use entity framework, you can do the wireing for your self.
In my ria 4 html demo, I make use of ria services to get the data from the server to the upshot client. This way it doesn't depend on the DAL you have. Ria services works by conventions, meaning insert, update and remove methods are present on every domaincontext and you can implement them as you want. For more info you can read this blogpost on setting everything up. And this on for the CRUD operations.

LINQ to SQL - To Use or Not To Use that is the Question

I come from a different language and there are always the different views about what to use and what not to use. What is your opinion and pros and cons on why to use or not use LINQ to SQL?
Also I saw there was a LINQ to NHibernate is this worth using if you have NHibernate?
I have not gotten NHibernate installed just yet.
Thanks
I would probably not recommend using LINQ to SQL at this point. If you're doing new development, I would recommend the ADO.NET Entity Framework instead.
This is a much more current, actively developed alternative to LINQ to SQL, as it's getting a lot of attention from Microsoft moving forward.
As for LINQ to Nhibernate... If you're already planning to use Nhibernate, this gives you the benefits of LINQ. I, personally, very much like using LINQ in my projects, as I find it makes my code faster to write and more maintainable, so I'd highly recommend this. I'd probably still favor EF over Nhibernate for .NET development (it's built into the framework, supported by MS, etc), however.
This is very hard to answer, without knowing what you want to build with it.
For small scale projects, it is my experience that you can get up-and-running with LINQ-to-SQL very easily, and it is easy to work with. It does however, lack some features (such as inheritance, I believe). Also, Microsoft has discontinued further development of LINQ-to-SQL.
The current ORM / Persistence Framework from Microsoft is Entity Framework 4. It is being actively developed by MS; it has more features than LINQ-to-SQL, and is being branded as being a better fit for enterprise scale applications. With EF4, you can use LINQ expressions in your queries, as you can with LINQ-to-SQL.
Another option is NHibernate, which I use for my current project, and in my experience, it is a bit of both worlds. It might be of some value to you, that it is open source. It is easy to get started with, but be prepared to spend some time learning more advanced concepts. LINQ-to-NHibernate is not quite mature in the version we are using (2.x), but I think it is being much improved in 3.0. You can make some queries in LINQ, but the good thing is, that you will be able to fall back on the very powerful HQL or the Criterion API; when you need it.
In my mind, these 3 are the largest ORM contenders in the .NET world at the moment. There is also Subsonic, or Castle ActiveRecord; which I have no experience with; but they should be suited for minor projects.
With all this being said, you need to carefully consider your requirements for an ORM, test out some (write some PoC code that mimics the data-access you will be doing; see how easy it is to get set up). There is easy Yes/No answer for this.

Text User Interface Design Reference?

Is there a good book or other references on Text User Interface Design? I am not interested in graphical user interfaces. I am interested in usability for good command line and scripting interfaces.
Your interface should follow the Rule of Least Surprise as described by ESR in The Art of Unix Programming. If your programm supports command line options, make sure they have the traditional meaning. Be sure to read the chapter about Tradeoffs between CLI and Visual Interfaces.
IBM developed a standard called Common User Access. The Common User Access Basic Interface Design Guide has been published in the BookManager format and in HTML here.
The guide was written as a standard for developing 3270 applications. In my opinion the most important parts are the function keys standard and a color standard.
I'd use a favorite program as a reference for something like this. What command line utility do you think has a good, efficient interface that you could model your program on? Use it.
Update: So I think I need to revise this a little. It was taken way too literally. Google and this site proved that the internet is very democratic. What is popular is replicated, linked to or reproduced in someway.
Given this, plus one's personal experiences with computers, I think it is feasible to derive a pretty good solution based on personal experience and consideration for the solution to be provided.
For example, vim is a great program. A lot of people use it and love it. But that type of interface is probably not going to work (at least well) for a version control system. But both interfaces are very elegant for the purpose they suite. On the other hand, the vim type interface might work for a section of the version control system -- the commit dialog for example.
Now, I know that vim is normally used for the "commit dialog" (by default) for svn (on unix based OSes). This is just an example of mixing two styles of interfaces to come up with a cohesive solution.
You should have a look at some of the ideas behind Ubiquity as well as some of the ideas Aza Raskin talks about, seems like the same kind of thing.

LinqToSql Best Practices

I just started creating my data-access layer using LinqToSql. Everybody is talking about the cool syntax and I really like Linq in general.
But when I saw how your classes get generated if you drag some tables on the LinqContext I was amazed: So much code which nobody would need?!
So I looked how other people used LinqToSql, for example Rob Connery at his StoreFront Demo.
As I don't like the way that all this code is generated I created my domain layer by hand and used the generated classes as reference. With that solution I'm fine, as I can use the features provided by Linq (dereferred execution, lazy loading, ...) and my domain layer is quite easy to understand.
How are you using LinqToSql?
The created classes are not as heavy as it seems. Of course it takes quite a few lines of code, but all in all it is as lightweight as it can be for the features it's providing.
I used to create my own tables, too, but now instead I just use the LINQtoSQL DataContext. Why? Creating is simpler, the features are better, interoperability works, it is probably even faster than my own stuff (not in every aspect. Usually my own stuff was extremely fast in one thing, but the generic stuff was faster in everything else).
But the most important part: it is easier to bring new developers into the LINQ stuff than into my own. There are tutorials, example codes, documentation, everything, which I'd have to create for my code by myself. Same with using my stuff with other technology, like WCF or data binding. There are a lot of pitfalls to be taken care of.
I learned not to develop myself into a corner the hard way, it looks fast and easy at the start, is a lot more fun than learning how to use the libs, but is a real pain in the a after a few months down the road, usually even for myself.
After some time the novelty of creating my own data containers wears off, and I noticed the pain connected to adding a feature. A feature I would have had for free, if I had used the provided classes.
Next thing I had to explain my code to some other programmer. Had I used the provided classes, I could have pointed him to some web site to learn about the stuff. But for my classes, I had to train him himself, which took a long time and made it hard to get new people on a project.
LinqToSql generates a set of partial classes for your tables. You can add interface definitions to the 'other half' of these partial classes that implement your domain model.
Then, if you use the repository pattern to wrap access to the Linq queries, so that they return interface implementations of your objects (the underlying Linq objects), LinqToSql becomes quite flexible.
You can hand-write your own classes and either use the LINQ to SQL attributes to declare the mappings or an external XML file.
If you would like to stick with the existing designer and just modify the code generation process pick up my templates that let you tailor the generated code.
Use compiled queries. Linq to SQL is dog slow otherwise. Really.
We use our hand crafted domain model, along with the generated classes, plus a simple utility which utilizes reflection to convert between them when needed. We've contemplated writing a converter generator if we reach a point where reflection creates a performance bottleneck.