[英]Erro when try to Update-Database
I am stuck with this error我被这个错误困住了
Cannot insert the value NULL into column 'FuncionarioId', table 'as.net-vet_plus-7C2DFFB7-3F35-42B0-88A6-094E42F60676.dbo.Endereco';无法将值 NULL 插入“FuncionarioId”列、表“as.net-vet_plus-7C2DFFB7-3F35-42B0-88A6-094E42F60676.dbo.Endereco”; column does not allow nulls.列不允许空值。 UPDATE fails.更新失败。
The statement has been terminated.该语句已终止。
When I run the Update-Database
to update my columns.当我运行Update-Database
来更新我的列时。
This is my C# code in the Endereco - model这是我在 Endereco 中的 C# 代码 - model
[Column("ClienteId")]
[Display(Name = "Cliente")]
[DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
public int ClienteId { get; set; }
[Column("FuncionarioId")]
[Display(Name = "Funcionário")]
[DisplayFormat(DataFormatString = "{0:N}", ApplyFormatInEditMode = true)]
public int FuncionarioId { get; set; }
public virtual Cliente Cliente { get; set; }
public virtual Funcionario Funcionario { get; set; }
I am trying to connect my Enderoco
database with the Cliente
and Funcionario
tables, the Enderoco table has to receive either a ClienteId or an FuncionarioId, it doesn't matter which one, but it must have one of the two.我正在尝试将我的Enderoco
数据库与Cliente
和Funcionario
表连接起来,Enderoco 表必须接收 ClienteId 或 FuncionarioId,哪个无关紧要,但它必须具有两者之一。
Does anyone know about this error and how to fix it?有谁知道这个错误以及如何解决它? Please, let me know!请告诉我!
You can add [Required]
attribute on FuncionarioId
.您可以在FuncionarioId
上添加[Required]
属性。 I think this can help you.我认为这可以帮助你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.