Error: "The target context 'Nop.Data.NopObjectContext' is not constructible. Add a default constructor or provide an implementation of IDbContextFacto

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
When I follow this tutorial www.nopcommerce.com/docs/75/plugin-with-data-access.aspx
use Add-Migration or Update-Database command, then occur error  "The target context 'Nop.Data.NopObjectContext' is not constructible. Add a default constructor or provide an implementation of IDbContextFactory."

help me please
11 years ago
is it a bug?
7 years ago
To avoid this issue you have to modify your NopObjectContext.
You have to add constructor without parameters and init connection string in it.

Example:

public NopObjectContext()
      : base("YourConectionString")
    { }



<connectionStrings>
    <!--This connection string is never using. See App_Data/Settings.txt-->
    <add name="YourConectionString"
         connectionString="Data Source=YourServerName;Initial Catalog=YourDataBase;Integrated Security=False;Persist Security Info=False;User ID=sa;Password=sa"
         providerName="System.Data.SqlClient" />
  </connectionStrings>
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.