System.InvalidOperationException HResult=0x80131509 Message=No
suitable constructor was found for entity type ‘Movie’. The following
constructors had parameters that could not be bound to properties of
the entity type: cannot bind ‘dierctory’ in ‘Movie(string dierctory)’.
Source=Microsoft.EntityFrameworkCore StackTrace: at
Microsoft.EntityFrameworkCore.Metadata.Conventions.ConstructorBindingConvention.ProcessModelFinalizing(IConventionModelBuilder
modelBuilder, IConventionContext`1 context)
问题:
我的代码Movie类有“有参”构造函数,但EF Core在初始化数据库时,无法使用“有参”构造函数初始化。参考StackOverflow。
详见微软文档
解决方案:
添加默认的构造函数,重载构造函数。