Jump to content

Photo
- - - - -

Unable to create an object of type 'SmartDbContext'

entityframework package-manager-console

  • Please log in to reply
1 reply to this topic

#1 shiranfe

shiranfe

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 09 July 2023 - 07:58

After installing the solution:

  • added refrence of "Smartstore.Data.SqlServer" to "Smartstore.Web" project
  • initated the DB.

I wanted to make some changes and update the DB.

I have selected in package manager console the "Smartstore.Core" as default project and run "add-migration [name of the migration]"

 

I have received following error:

 

An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error: Could not load file or assembly 'C:\Users\shira\.nuget\packages\microsoft.entityframeworkcore.tools\7.0.8\tools\netcoreapp2.0\any\Smartstore.Data.SqlServer.dll'. The system cannot find the file specified.

Unable to create an object of type 'SmartDbContext'. For the different patterns supported at design time, see https://go.microsoft.../?linkid=851728

 

Any Advice?


#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3823 posts

Posted 10 July 2023 - 20:53

"added refrence of "Smartstore.Data.SqlServer" to "Smartstore.Web" project"
 
This is neither necessary nor recommended.
 
"initated the DB."
 
Whatever is meant by this, the database is created automatically during the Smartstore installation. This includes schema changes that are initiated by modules. It is neither necessary nor recommended to interfere there.
 
"I wanted to make some changes and update the DB."
 
Read and follow the instructions in the developer guide:
 
Take a look at sample modules and their data migration, e.g. here.

Marcus Gesing

Smartstore AG