I have compared my setup to the other plugins that came out of the box and it looks the same from what I can see. First I have a model that looks like this:
public partial class MyCustomEntity: BaseEntity
{
public int ProductId { get; set; }
public bool Status { get; set; }
public bool IsDeleted { get; set; }
public DateTime? InTime { get; set; }
public int StoreId { get; set; }
public int LanguageId { get; set; }
}
Each of these properties correspond to a column in the SQL Server table.
Then it is used in the service like this:
public partial class MyCustomService: IMyCustomService
{
...
private readonly IRepository<MyCustomEntity> _myCustomEntityRepository;
...
public MyCustomService(IRepository<MyCustomEntity> myCustomEntityRepository)
{
_myCustomEntityRepository = myCustomEntityRepository;
}
...}
And in the DependencyRegistrar, the service is registered like so:
public void Register(ContainerBuilder builder, ITypeFinder typeFinder, NopConfig config)
{
...
builder.RegisterType<MyCustomService>().As<IMyCustomService>().InstancePerLifetimeScope();
}
With this setup, the myCustomEntityRepository comes through as NULL.
Now in 3.8, along with the service, this custom entity would also be registered here in the DependencyRegistrar, but I have noticed now in 4.3, the other plugins do not seem to be doing this anymore, they appear to just be magically working without it. Nevertheless, I tried adding it in anyway like before:
builder.RegisterType<IRepository<MyCustomEntity>>()
.As<IRepository<MyCustomEntity>>()
.WithParameter(ResolvedParameter.ForNamed<INopDataProvider>("nop_object_context_my_custom_entity"))
.InstancePerLifetimeScope();
but then this throws the following error on startup:
NoConstructorsFoundException: No accessible constructors were found for the type 'Nop.Data.IRepository`1[[My.Plugin.Name.MyCustomEntity, My.Plugin.Name, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
Not sure why this isn't working, or how Nop knows how to populate the IRepository of other plugins without explicitly registering them. Been stuck on this for a while so any help is appreciated. Thanks!