Wanted to restore my database by using ADO.Net Entity Framework

Osama Younus 1 Reputation point
2022-04-23T20:53:24.307+00:00

I have been hacked by someone all my system. I have one project where I used ADO.Net Entity Framework, Now I want to restore my database by that ADO.Net can anyone help how I can do it?

Azure SQL Database
Entity Framework 6.0
Entity Framework 6.0
A Microsoft open-source object-database mapper for .NET.
243 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
1,147 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,175 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Karen Payne MVP 31,001 Reputation points
    2022-04-23T21:28:38.12+00:00

    The best method to restore your database is (assuming SQL-Server) through SSMS (SQL-Server Management Studio) provided you had first backup the database or in SSMS generated scripts to a .sql file.

    For a basic template for code using a data provider as there is real no gain in doing this with EF. But as stated above you need to have a current backup file.

    Note the path may differ from your install or it may be in the cloud.

    ALTER DATABASE [TODO] 
    SET SINGLE_USER WITH ROLLBACK IMMEDIATE; RESTORE DATABASE [TODO] 
        FROM  DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\Backup\TODO.bak' 
        WITH REPLACE; ALTER DATABASE [TODO] SET MULTI_USER;
    
    1 person found this answer helpful.

  2. Alberto Morillo 27,546 Reputation points MVP
    2022-04-23T22:19:02.047+00:00

    Please try to use the update-database command to migrate/create your database on Azure SQL Database.

    Create your empty database on Azure SQL first, and configure Azure SQL firewall to allow your client IP Address to connect to the database.


  3. Bruce (SqlWork.com) 35,791 Reputation points
    2022-04-25T22:53:41.873+00:00

    I assume by restore, you don't mean restore from a backup (which you should have been maintaining).

    We would need to know more about how you created the database first. Was it database first? was it code first? if code first, you probably just need a new empty database.

    https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/workflows/new-database

    0 comments No comments