I have following error when I try out this example. I can't figure out what I did wrong
Severity Code Description Project File Line Suppression State Error CS0308 The non-generic method 'IColumnOptionSyntax<ICreateTableColumnOptionOrWithColumnSyntax, ICreateTableColumnOptionOrForeignKeyCascadeOrWithColumnSyntax>.ForeignKey(string, string)' cannot be used with type arguments Nop.Plugin.Other.ProductViewTracker D:\VS2019\nopCommerce430Dev\Plugins\Nop.Plugin.Other.ProductViewTracker\Data\ProductViewTrackerRecordBuilder.cs 21 Active
using FluentMigrator.Builders.Create.Table; using Nop.Data.Mapping.Builders; using Nop.Core.Domain.Customers; using Nop.Plugin.Other.ProductViewTracker.Domain; using System.Data; using Nop.Core.Domain.Catalog;
namespace Nop.Plugin.Other.ProductViewTracker.Data { public class ProductViewTrackerRecordBuilder : NopEntityBuilder<ProductViewTrackerRecord> { /// <summary> /// Apply entity configuration /// </summary> /// <param name="table">Create table expression builder</param> public override void MapEntity(CreateTableExpressionBuilder table) { //map the primary key (not necessary if it is Id field) table.WithColumn(nameof(ProductViewTrackerRecord.Id)).AsInt32().PrimaryKey() //map the additional properties as foreign keys .WithColumn(nameof(ProductViewTrackerRecord.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.Cascade) .WithColumn(nameof(ProductViewTrackerRecord.CustomerId)).AsInt32().ForeignKey<Customer>(onDelete: Rule.Cascade) //avoiding truncation/failure //so we set the same max length used in the product name .WithColumn(nameof(ProductViewTrackerRecord.ProductName)).AsString(400) //not necessary if we don't specify any rules .WithColumn(nameof(ProductViewTrackerRecord.IpAddress)).AsString() .WithColumn(nameof(ProductViewTrackerRecord.IsRegistered)).AsInt32(); } } }
This error only pops up after I add using FluentMigrator.Builders.Create.Table; and why does it only cause issue with .WithColumn(nameof(ProductViewTrackerRecord.ProductId)).AsInt32().ForeignKey<Product>(onDelete: Rule.Cascade)
but not .WithColumn(nameof(ProductViewTrackerRecord.CustomerId)).AsInt32().ForeignKey<Customer>(onDelete: Rule.Cascade)