I created the project SqlSharpener which should be able to do what you're asking.
For example, given these tables defined in an SSDT project:
CREATE TABLE [dbo].[Tasks]
(
[Id] INT NOT NULL PRIMARY KEY IDENTITY,
[Name] VARCHAR(50) NOT NULL,
[Description] VARCHAR(1000) NOT NULL,
[TaskStatusId] INT NOT NULL,
[Created] DATETIME NOT NULL ,
[CreatedBy] VARCHAR(50) NOT NULL,
[Updated] DATETIME NOT NULL,
[UpdatedBy] VARCHAR(50) NOT NULL,
CONSTRAINT [FK_Tasks_ToTaskStatus] FOREIGN KEY ([TaskStatusId]) REFERENCES [TaskStatus]([Id])
)
CREATE TABLE [dbo].[TaskStatus]
(
[Id] INT NOT NULL PRIMARY KEY,
[Name] VARCHAR(50) NOT NULL
)
You can create a T4 template that will generate the entities as such:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
namespace SimpleExample.EntityFrameworkCodeFirst
{
public partial class TaskContext : DbContext
{
public TaskContext(): base()
{
}
public DbSet<Tasks> Tasks { get; set; }
public DbSet<TaskStatus> TaskStatus { get; set; }
}
[Table("Tasks")]
public partial class Tasks
{
[Key]
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Int32? Id { get; set; }
[Required]
[MaxLength(50)]
public String Name { get; set; }
[Required]
[MaxLength(1000)]
public String Description { get; set; }
[Required]
public Int32? TaskStatusId { get; set; }
[ForeignKey("Id")]
public virtual TaskStatus TaskStatus { get; set; }
[Required]
public DateTime? Created { get; set; }
[Required]
[MaxLength(50)]
public String CreatedBy { get; set; }
[Required]
public DateTime? Updated { get; set; }
[Required]
[MaxLength(50)]
public String UpdatedBy { get; set; }
}
[Table("TaskStatus")]
public partial class TaskStatus
{
[Key]
[Required]
public Int32? Id { get; set; }
public virtual ICollection<Tasks> Tasks { get; set; }
[Required]
[MaxLength(50)]
public String Name { get; set; }
}
}
There is a working example of this T4 template in the simple example solution. If there is a use case that SqlSharpener doesn't currently handle, feel free to add an issue and I'll see if I can add it in.