Last post Jan 30, 2021 12:15 AM by wavemaster
Jan 25, 2021 08:48 PM|Robert-400|LINK
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.
Jan 26, 2021 01:04 AM|DA924|LINK
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)
Jan 26, 2021 02:49 AM|Sean Fang|LINK
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').
NuGet Gallery: https://www.nuget.org/packages/WebMatrix.Data/
Jan 26, 2021 06:33 AM|Mikesdotnetting|LINK
The Database class is not supported by Visual Studio.
Jan 30, 2021 12:15 AM|wavemaster|LINK
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.