Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't do the database migration/update. #1

Closed
ron-zhong opened this issue Nov 25, 2019 · 1 comment
Closed

Can't do the database migration/update. #1

ron-zhong opened this issue Nov 25, 2019 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@ron-zhong
Copy link

Hi,

I'm trying to run your code but met a problem on creating the database schema through using code-first approach as fellowing:

PM> add-migration MicrosofteShopOnWebCatalogDbContext -context MicrosofteShopOnWebCatalogDbContext
To undo this action, use Remove-Migration.
PM> update-database -context MicrosofteShopOnWebCatalogDbContext
System.ArgumentException: GenericArguments[0], 'DotnetCrawler.Data.Migrations.MicrosofteShopOnWebCatalogDbContext', on 'Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory1[TContext]' violates the constraint of type 'TContext'. ---> System.TypeLoadException: GenericArguments[0], 'DotnetCrawler.Data.Migrations.MicrosofteShopOnWebCatalogDbContext', on 'Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory1[TContext]' violates the constraint of type parameter 'TContext'.
at System.RuntimeTypeHandle.Instantiate(RuntimeTypeHandle handle, IntPtr* pInst, Int32 numGenericArgs, ObjectHandleOnStack type)
at System.RuntimeTypeHandle.Instantiate(Type[] inst)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
--- End of inner exception stack trace ---
at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e)
at System.RuntimeType.MakeGenericType(Type[] instantiation)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextFactory(Type contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextTypes()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextType(String name)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
GenericArguments[0], 'DotnetCrawler.Data.Migrations.MicrosofteShopOnWebCatalogDbContext', on 'Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory`1[TContext]' violates the constraint of type 'TContext'.

@mehmetozkaya mehmetozkaya self-assigned this Dec 2, 2019
@mehmetozkaya mehmetozkaya added the question Further information is requested label Dec 2, 2019
@mehmetozkaya mehmetozkaya pinned this issue Dec 2, 2019
@mehmetozkaya
Copy link
Owner

Hi Ron,
In order to run this repository, you shouldn't need to add-migration and update-database EF commands. Because its not used code-first approach of Entity Framework.
Instead of this, I assume that you have an exiting database like e-commerce database and you will try to load your Catalog table in your database. For example of existing database I selected, Microsoft eShopOnWeb database. So you should use code-first approach in order to generate this database from target repository.
In this sample project, implementing Microsoft eShopOnWeb repository. You can find this repo here. In this example repository is implemented e-commerce project, it has “Catalog” table when you generate with EF.Core code-first approach. So before using the crawler, you should download and run this project with a real database. To perform this action, please refer to this information. (If you have an already existing database, you can continue with your database.)
So basically, my aim was to explain how to adapt your crawler with existing database.

@mehmetozkaya mehmetozkaya added good first issue Good for newcomers and removed question Further information is requested labels Dec 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants