locked
Database Class in Visual Studio RRS feed

  • Question

  • User1504070297 posted

    Hi,

      I really like WebMatrix. But I need to move my code to Visual Studio. I use the WebMatrix Database class. The Database class is not supported by Visual Studio. I know how to use the SqlConnection class. The problem is my code is about 14,000 lines of code and I think I use the Database class at least 100 times. To manually convert all that code to the SqlConnection class would be very time consuming and extremely error prone.

    Is there any way of using the Database class in Visual Studio? I sure hope so. I miss WebMatrix.

    Thanks,

    Robert

    Monday, January 25, 2021 8:48 PM

All replies

  • User1120430333 posted

    You have a single class with 14,000 lines of code cannot be an optimal approach. Maybe you should consider using some kind of SoC by using a DAL that uses the DAO pattern.

    Separation of concerns - Wikipedia

    Data Access Object (DAO) design pattern in Java - Tutorial Example (javarevisited.blogspot.com)

    Tuesday, January 26, 2021 1:04 AM
  • User-1330468790 posted

    Hi Robert-400,

     

    Is there any way of using the Database class in Visual Studio?

    Do you mean that you cannot use one specific class, WebMatrix.Data.Database, in Visual Studio? 

    You could simply add one assembly WebMatrix.Data in your project using either Package Manager Console or NuGet Package Manger (search 'WebMatrix.Data').

    Reference:

    NuGet Gallery: https://www.nuget.org/packages/WebMatrix.Data/

      

    Hope helps.

    Best regards,

    Sean

    Tuesday, January 26, 2021 2:49 AM
  • User-821857111 posted

    The Database class is not supported by Visual Studio.
    Yes it is. What issues are you getting?

    Tuesday, January 26, 2021 6:33 AM
  • User379720387 posted

    You can keep doing things the WebMatrix way in VS.

    In VS2019 you create a new project and you look for ASP.NET Web Site (Razor v3) either C# or VB.

    Copy all your files over in the appropriate folders, and that should be it if I remember correctly (It has been about 7 years ago since I did this).

    You can even consider using SQL Express over SQL Compact as there is no direct support for .sdf files. You would need a VS plug in for that and that has a few draw backs.

    I had resisted switching over the SQL Express, but a friend insisted that I wouldn't look back. And I didn't.

    Saturday, January 30, 2021 12:15 AM