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;