ASPNET-添加迁移时的故障:值不能为null,参数名称:属性



我已经在网络中查找此错误,我找不到任何有用的。我尝试在dotnet中使用实体框架创建数据库,但我遇到了这个错误。有什么建议我做错了什么?我想提供代码,但我不知道哪一个。如果需要的话,我稍后再进行更新。现在我只附加错误。

system.argumentNullexception:值不能为null。 参数名称:属性 在Microsoft.entityframeworkcore.utilities.check.notnull [t](t值,字符串parametername) 在Microsoft.entityframeworkcore.storage.RelationalTypemapper.findmapping(iProperty属性) 在Microsoft.entityframeworkcore.migrations.mysqlmigrationssqlgenerationhelper.columndefinition(String Schema,Strin,Strin) G表,字符串名称,类型clrtype,字符串类型,无效1 unicode, Nullable 1 MaxLength,Boolean Rowversion,boolean 无效的,对象默认值,字符串DefaultValuesql,String ComputedColumnsql,Iannotatable Annotatable,Imodel模型 ,MigrationCommandListBuilder Builder) 在Microsoft.entityframeworkcore.migrations.migrationssqlgenerator.columndefinition(addColumnoperation操作,IM) ODEL模型,Migration -CommandListBuilder Builder) 在Microsoft.entityframeworkcore.migrations.migrationssqlgenerator.generate(createTableOperation操作,imodel m) Odel,MigrationCommandlistBuilder Builder,Boolean终止) 在Microsoft.entityframeworkcore.migrations.migrationssqlgenerator.generate(createTableOperation操作,imodel m) Odel,MigrationCommandListBuilder Builder) 在Microsoft.entityframeworkcore.migrations.migrationssqlgenerator.generate(迁移操作,Imodel mod) El,MigrationCommandListBuilder Builder) 在Microsoft.entityFrameworkcore.migrations.migrationssqlgenerator.generate(Ireadonlylist'1操作,iModel模型) ) 在microsoft.entityframeworkcore.migrations.internal.migrator.generateUpsql(迁移迁移) 在Microsoft.entityframeworkcore.migrations.internal.migrator.migrate(字符串目标移民) 在Microsoft.entityframeworkcore.design.internal.migrationsoperations.updatedatabase(字符串Target Mogration,String,String 上下文类型) 在Microsoft.entityFrameworkcore.design.operationexecutor.updatedatabase。 在Microsoft.entityframeworkcore.design.operationexecutor.operationbase.execute(Action Action) 值不能为null。 参数名称:属性 重构stacktrace

任何回应都会很棒。非常感谢。

谢谢你们的帮助。我现在知道这个问题。它只是在表名中输入错字。

public DbSet<Account> tblAccount {get;set;}

然后我将其写在迁移代码

migrationBuilder.CreateTable(
            name: "tblAccounts ",
            columns: table => new ....

我很抱歉我没有意识到。

您正在尝试发送null值的null值,该参数/列是类型而不是null。

最新更新