Saq*_*taq 4 c# ef-code-first entity-framework-core entity-framework-migrations ef-core-6.0
我正在 Entity Framework Core 6.0 中创建一个数据库表。我在我的项目中使用代码优先方法。
TestModelname中有一个字符串类型属性Address。
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace TestProjectForCore6.Models
{
public class TestModel
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Address { get; set; }
}
}
Run Code Online (Sandbox Code Playgroud)
当我为此模型添加迁移时,它会nullable false在迁移构建器中创建一个列:
在 Entity Framework Core 5.0 中,我们不需要添加显式定义字符串属性为可为空。
| 归档时间: |
|
| 查看次数: |
9926 次 |
| 最近记录: |