13

I am looking for a simple CRUD (or DAL) Generator for C#. I don't want anything heavyweight since I only have a couple of tables in a SQL Server 2008 database.

Any suggestions? I know .netTiers, but it is way too much for what I need.

Thanks!

UPDATE: I tried LINQ to SQL and it doesn't work well for my needs.

Martin
  • 39,309
  • 62
  • 192
  • 278
  • If you want an Angular web interface with a RESTful WebAPI service, check out: https://github.com/capesean/codegenerator3 – Sean Jun 09 '22 at 08:34

13 Answers13

10

I have used SubSonic on past projects, it's lightweight and easy to use.

They offer a simple tutorial video and it should take no more than 10 minutes to get it completely setup. I recommend watching the second half of the video that deals with Web Application Projects because it shows you how to create a customized Visual Studio button that creates the DAL for you whenever you click on it instead of using a custom build-provider as they suggest in first half of the video.

It offers several ways to access your data, Active Record, generating typed stored-procedures and views, or a query language that you can use.

After using it, I have found a few quirks:

  • If you use a generated stored-procedure that does not have a parameter, it will throw a NullReferenceException. A workaround is to create a dummy parameter that isn't used in the procedure
  • The DeepSave() function does not work in the current 2.1 version, you'll have to individually save data from joined tables
  • When you use a coditional (e.g. Where(Tag.Columns.TagName).IsEqualTo("subjective"), make sure you use the string value Tag.Columns.TagName to reference the column - otherwise an exception will be thrown if you try to use the Column.Schema
Community
  • 1
  • 1
John Rasch
  • 62,489
  • 19
  • 106
  • 139
  • Subsonic is probably the lightest DAL maker that I have found so far. Everything else has become far too bloated. Try version 2.1, which now has an installer. – Hector Sosa Jr Mar 23 '09 at 03:03
  • 2
    Your links are dead; you'll have to update them to point to the new site at http://subsonic.github.io/ I guess, insofar possible. – Martijn Pieters Apr 27 '15 at 19:29
  • The SubSonic project doesn't appear to have been updated in the past 2 years. – John M Jan 13 '16 at 21:33
7

Visual Studio comes with a code generator that hardly anyone knows about called T4.

You should be able to use it relatively easily to create CRUD templates.

EDIT

And here's an example how: http://www.olegsych.com/2008/01/how-to-use-t4-to-generate-crud-stored-procedures/

Giovanni Galbo
  • 12,963
  • 13
  • 59
  • 78
3

try http://pureobjects.com/ it is not need any other work

  • 1
    I've used pureobjects many times. It works great gives you everything from the DAL to the objects. Insert, Update, Delete statements classes everything. Just put in your table info and it does it all!! – Kaos Feb 11 '12 at 18:10
  • pureobjects link appears to be invalid. It takes you to some other non-programming webpage. – John M Jan 13 '16 at 21:36
  • @JohnM It is working now to DAL crud page – Ahmed Samir Hasan Mar 03 '19 at 07:36
3

MyGeneration has some pretty good CRUD SP generation templates

MrTelly
  • 14,657
  • 1
  • 48
  • 81
  • at 2016.01.11 -> the MyGeneration link appears to have expired and is now displaying a 'place holder' page. – John M Jan 12 '16 at 03:54
2

What about using a DataSet created using the DataSet designer. I remember back in the Old Days (.NET 1.0 and 1.1), we would drag a DataAdapter onto the design surface, specify the Select query, and the Insert, Update and Delete queries would be created for us, based on the Select query.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
2

Just in case money isn't a big concern, I've had great success with templates in CodeSmith.

There are plenty of sample templates out there for CRUD operations and it'll read directly from your database.

Damovisa
  • 19,213
  • 14
  • 66
  • 88
  • I agree, I use code smith for lightweight stuff, it is also easy to write your own templates if you are trying to integrate into an existing project which can be really handy. – Element Mar 23 '09 at 02:59
2

Take a look at Codesmith. The 2.6 version is free and the later versions are for purchase.

Bill Martin
  • 4,825
  • 9
  • 52
  • 86
1

LINQ To SQL is easy and it's built into .NET 3.5 SP1.

Paul Mendoza
  • 5,709
  • 12
  • 53
  • 82
  • 2
    It is what I have been trying to use for a couple of days and it is a nightmare. Espacially that I have M:M relation... – Martin Mar 23 '09 at 02:13
1

The Visual Studio wizards will create a simple CRUD app for you.

Drag a datagrid on your form, click the connection property and follow the wizards from there.

Not best practices but is simple and works...

jason saldo
  • 9,804
  • 5
  • 34
  • 41
1

Have you tried the Dynamic Data Web Application (uses LINQ to SQL) or the Dynamic Data Entities Web Application (uses Entity Framework).

MSDN: Walkthrough: Creating a New ASP.NET Dynamic Data Web Site Using Scaffolding

bendewey
  • 39,709
  • 13
  • 100
  • 125
1

I use ssms tools pack

mracoker
  • 886
  • 9
  • 14
1

I was using SubSonic 3 ActiveRecord but have since moved to BLToolkit. BLToolkit is much harder to get started with due to the lack of good documentation, but once you get used to it, it's very much like SubSonic... except for without the performance issues.

SubSonic is great and easy but the performance is unbearable for anything practical. Anytime a join or subquery is done it will pull down entire tables.

Earlz
  • 62,085
  • 98
  • 303
  • 499
0

Check out LLBLGen Pro, I swear by it. It is not free, but not expensive. You can get up and running (writing code) within an hour, and the templates it comes with generate code that can do basically anything you would want. It is so nice (and productive) to not even have to think about database interface code anymore.

tbone
  • 5,715
  • 20
  • 87
  • 134