admin管理员组

文章数量:1128465

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:

  • Maintain the DB schema in a SQL Project (.sqlproj) - including tables, views, stored procedures, and user-defined functions
  • In the same solution, have a .NET DAL library that consumes the schema definitions and generates DbContext with entity classes

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?

本文标签: