Type 型のプロパティを持つオブジェクトがあります。
public ScheduledJob
{
public int ID { get; set; }
public Type JobType { get; set; }
public string JobParameters { get; set; }
}
コード ファーストの移行を生成すると、次のエラーが発生します。
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.SortedEntityTypeIndex.Add(EdmEntitySet entitySet, EdmEntityType entityType)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingService.Analyze()
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.LazyInternalContext.get_CodeFirstModel()
at System.Data.Entity.Infrastructure.EdmxWriter.WriteEdmx(DbContext context, XmlWriter writer)
at System.Data.Entity.Migrations.Extensions.DbContextExtensions.<>c__DisplayClass1.<GetModel>b__0(XmlWriter w)
at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(Action`1 writeXml)
at System.Data.Entity.Migrations.Extensions.DbContextExtensions.GetModel(DbContext context)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext)
at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration)
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.GetMigrator()
at System.Data.Entity.Migrations.Design.ToolingFacade.GetPendingMigrationsRunner.RunCore()
at System.Data.Entity.Migrations.Design.ToolingFacade.BaseRunner.Run()
このシナリオを機能させる最善の方法は何ですか?
@NSGaga の投稿の編集:
モデル全体(簡略化)は次のとおりです。
すべてのジョブ オブジェクトは、次のインターフェイスを実装します。
public interface IJob
{
Guid ID { get; set; }
void Run();
}
各ジョブには、一種のパラメーターとして使用される独自のプロパティがあります。
public class ProcessMedia : IJob
{
public Guid ID { get; set; }
public int MediaContentID { get; set; }
public void Run()
{
if(MediaContentID <= 0)
throw new Exception("Missing parameter MediaContentID");
//work
}
}
私はこのモデルを非同期ジョブ処理システムに使用していますが、これは正常に動作します。ここで、ジョブの種類とパラメーター (文字列にシリアル化) を指定して、間隔を置いて実行できるスケジューラーを作成しようとしています。