Entity Framework Core Code First

参考地址:https://docs.microsoft.com/zh-cn/ef/core/get-started/aspnetcore/new-db

Add-Migration myfirstcode

报错:The property 'MessageModel.Data' could not be mapped, because it is of type 'object' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.

主要是因为没model中属性有不常规的类型。例如属性是枚举类型,可以使用 [NotMapped]忽略。

 

 

Update-Database

 

安装的包:

Microsoft.EntityFrameworkCore

Microsoft.EntityFrameworkCore.Tools

Pomelo.EntityFrameworkCore.MySql

posted @ 2018-03-11 20:07  longdb  阅读(583)  评论(0编辑  收藏  举报