Значение не может быть нулевым. Имя параметра: экстент
Я сначала использую код EF6 для создания моей базы данных. Все работало хорошо прошлой ночью, теперь, когда я запускаю команду update-database, я получаю следующее исключение:
PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.ArgumentNullException: Value cannot be null.
Parameter name: extent
at System.Data.Entity.Utilities.Check.NotNull[T](T value, String parameterName)
at System.Data.Entity.Core.Mapping.StorageEntitySetMapping..ctor(EntitySet extent, StorageEntityContainerMapping entityContainerMapping)
at System.Data.Entity.ModelConfiguration.Edm.DbDatabaseMappingExtensions.AddEntitySetMapping(DbDatabaseMapping databaseMapping, EntitySet entitySet)
at System.Data.Entity.ModelConfiguration.Edm.Services.TableMappingGenerator.Generate(EntityType entityType, DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.GenerateEntityTypes(DbDatabaseMapping databaseMapping)
at System.Data.Entity.ModelConfiguration.Edm.Services.DatabaseMappingGenerator.Generate(EdmModel conceptualModel)
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.Utilities.DbContextExtensions.c__DisplayClass1.b__0(XmlWriter w)
at System.Data.Entity.Utilities.DbContextExtensions.GetModel(Action`1 writeXml)
at System.Data.Entity.Utilities.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.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.c__DisplayClass2.b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Value cannot be null.
Parameter name: extent
Вот класс контекста
public class WheelTrackDb : DbContext
{
public WheelTrackDb(): base("DefaultConnection"){ }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity()
.HasRequired(d => d.Vehicle)
.WithOptional(v => v.Driver)
.Map(m => m.MapKey("VehicleId"));
modelBuilder.Entity()
.HasRequired(t => t.Acceptor)
.WithMany()
.HasForeignKey(t => t.AcceptorId)
.WillCascadeOnDelete(false);
modelBuilder.Entity()
.HasRequired(t => t.Donor)
.WithMany()
.HasForeignKey(t => t.DonorId)
.WillCascadeOnDelete(false);
modelBuilder.Entity()
.HasRequired(v => v.GSMDeviceLog)
.WithMany(g => g.Violations)
.HasForeignKey(v => v.GSMDeviceLogId);
modelBuilder.Entity().Ignore(r => r.PolygonVertices);
modelBuilder.Entity()
.HasRequired(v => v.License)
.WithRequiredPrincipal();
modelBuilder.Entity()
.HasRequired(m => m.License)
.WithOptional(l => l.MessageCounter)
.Map(m => m.MapKey("LicenseId"));
modelBuilder.Entity()
.HasRequired(g => g.Vehicle)
.WithMany(t => t.GsmDeviceLogs);
}
public DbSet UserInfos{ get; set; }
public DbSet TransactionLogs{ get; set; }
public DbSet Drivers { get; set; }
public DbSet Vehicles{ get; set; }
public DbSet VehicleGroups { get; set; }
public DbSet Licenses { get; set; }
public DbSet Policys { get; set; }
public DbSet GSMDeviceLogs { get; set; }
public DbSet MessageCounters { get; set; }
public DbSet Violations { get; set; }
public DbSet OwnershipPapers { get; set; }
public DbSet Subscribers { get; set; }
}
А вот Конфигурация: я
internal sealed class Configuration : DbMigrationsConfiguration
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
}
protected override void Seed(WheelTrack.Models.WheelTrackDb context)
{
}
}
Я искал в интернете и обнаружил, что у меня должны быть свойства только в моем классе контекста. И я проверил трижды, он имеет только свойства dbset. Я'Я не могу понять, что произошло. Любая помощь будет принята с благодарностью. Благодарю.