Create C# Model From TSQL Table

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
Site Admin
Posts: 2547
Joined: Fri Aug 13, 2004 5:10 pm

Create C# Model From TSQL Table

Post by jussij »

The attached zip file contains a TSQL stored procedure that can be used to create a C# Model for a given TSQL table.

usage: EXEC [dbo].[sp_ModelFromTable] tblExample

Running that stored procedure will produced the model shown below:

Code: Select all

using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Database.Model
    [Table("tblExample", Schema = "dbo")]
    public class tblExampleModel
        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int ID { get; set; }
        public string Name { get; set; }
(1.92 KiB) Downloaded 25 times
Post Reply