I am creating a Web API application using EF with a code-first approach in Visual Studio 2017. I tried to use enable-migration
, initially I was not working so I installed these packages.
Install-Package Microsoft.EntityFrameworkCore.Tools -Version 2.2.3
Install-Package Microsoft.EntityFrameworkCore.SqlServer
After installing those packages, enable-migration
worked for me, but when I tried to add a migration using Add-Migration FirstMigration
command, it throws an error
No DbContext was found in assembly 'UserRegistration'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.
Please help me how to resolve this issue in Visual Studio 2017.
PS : I have also defined the DBbConnection
in my web.config
file:
<connectionString>
<add name="DefaultConnection"
connectionString="Data Source=(local);Initial Catalog=WebAPIDB;Integrated Security=True"
providerName="System.Data.SqlClient"></add>
</connectionString>