T-SQL + C# + JavaScript data compatibility (MVC)

I work full stack on many software projects. I create my tables and Stored Procedures on MS SQL Server.

Sometimes a database that I am developing can have more than a hundred tables. And thousands of columns and data structures…

Then I come to the C# side, I prepare datatable vs. on the ado.net side for my stored procedures with Table-Valued Parameters. I redefine the parameters and variables separately in accordance with the tables that I defined in ms sql.

In C#, I create classes again in accordance with the table columns I created on MS SQL.

And finally, I exchange data between C# and JavaScript (between front-end and back-end) with JSON. By applying Serialize to a class in C#…

But before serializing, I create classes (or struct or model, whatever) equivalent to the tables (columns) I created on the JavaScript side, so that I can exchange data between JSON and C# and JavaScript.

Thus, data is exchanged between MS SQL and C# via ADO.NET Table-Valued Parameter, and between C# and JavaScript with JSON.

In short, in order to use the model side of the MVC structure, I have to create C# (class) and JavaScript (class/structure) data models over and over again in accordance with the tables (and columns) I created on the MS SQL side.

Now there are 3 important points about it.

  1. My only solution was to develop an auto-script generator so that I could create a common pattern between T-SQL, C# and JavaScript. Because I developed a software in C# in order not to create the same data model as a table in T-SQL, as a class in C# and as a class/struct in JavaScript. First, I read all my own database, that is, my tables, columns and data structures through ADO.NET, and then I had C# classes and JavaScript classes/structures produced as scripts with the information ADO.NET provided me. This prevented me from wasting my time developing the same data structures separately for T-SQL, for C#, and for JavaScript.

  2. Of course, according to this situation, it required me to write my data structures as T-SQL first and create a database first. So somehow I chose to define data with T-SQL as a starting point.

  3. This was a solution I found myself and I would like to hear how other people are dealing with this situation. Is there any other effective solution for each platform (T-SQL, C# and JavaScript and more) that I haven’t seen? Or did I not see it?

I await your comments. Thanks…