I have to use City as drop down after state selection for this I have to create new table City. Can anyone please suggest what to do I have added new domain entity City in Core project and it's mapping in Data project and all place I have used now CityId instead of City as text input. After successful build no changes reflect in database.
I have also tried ef migration but getting this error.
PM> dotnet ef migrations add InitialCreate Unable to create an object of type 'NopObjectContext'. Add an implementation of 'IDesignTimeDbContextFactory<NopObjectContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time. PM> dotnet ef migrations add AddCity Unable to create an object of type 'NopObjectContext'. Add an implementation of 'IDesignTimeDbContextFactory<NopObjectContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
We are doing customization for new eCommerce site using nopCommerce latest version 4.1.
This is what I am getting when i tried to update the existing table in Nop Commerce 4.1 using code first approach
PM> Add-Migration InitialCreate
Unable to create an object of type 'NopObjectContext'. Add an implementation of 'IDesignTimeDbContextFactory<NopObjectContext>' to the project, or see https://go.microsoft.com/fwlink/?linkid=851728 for additional patterns supported at design time.
Yes, I'm doing manually in SQL database changes. Accordingly i do change in Core & Data project.
As of now .Net Entity framework Core do not support auto migration in Code first. Either you have to use do Migration each time or manage Manually. I prefer manually as i know what script i have to run on my production DB.
@Hezy has said it rightly that we need to do manually. :)
If you change NopObjectContext file as below, then you can easily run the add-migration command. Consider if you already have a database and now you want to add migration for the first time, after running the add-migration command you must delete all the codes from Up and Down methods. These codes are generated automatically in the migration class because EF core doesn't support -IngoreChanges option now.