You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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'.
The text was updated successfully, but these errors were encountered:
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.
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.IDesignTimeDbContextFactory
1[TContext]' violates the constraint of type 'TContext'. ---> System.TypeLoadException: GenericArguments[0], 'DotnetCrawler.Data.Migrations.MicrosofteShopOnWebCatalogDbContext', on 'Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory
1[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'.
The text was updated successfully, but these errors were encountered: