kolejarz
kolejarz

Reputation: 11

Generating EF Core (or Dapper) classes from .sqlproj T-SQL definitions using T4 or Roslyn Source Generators

I’m working in a .NET Core solution where the DBAs team has mandated using a .sqlproj (SQL Project) as the single source of truth for our SQL database schema. Because of that, we can’t rely on EF Core’s code-first approach and don't have direct access to live DBs. Instead, my team wants to generate our entity classes directly from the T-SQL definitions in the .sqlproj

My vision is:

Is there a known way to hook T4 templates or Roslyn source generators directly into a .sqlproj so that it can parse the T-SQL and generate C# code automatically (in separate project)? Or do I need a separate build step (e.g., generating a DACPAC and parsing that) to produce these classes?

Upvotes: 1

Views: 56

Answers (0)

Related Questions