环境:
EF core 2.0
Net core 2.0
错误:
因实体定义了多个key,打开数据库时程序报以下错误
An unhandled exception occurred while processing the request.
InvalidOperationException: Entity type '***' has composite primary key defined with data annotations. To set composite primary key, use fluent API.
具体的意思是无效的操作异常:实体(****)使用"data annotations"的方式已经定义了复合key。设置复合key,请使用“fluent API”方式。
解决方式:
官方文档 http://msdn.microsoft.com/en-us/data/JJ591617.aspx#1.2
There are two main ways you can configure EF to use something other than conventions, namely annotations or EFs fluent API. The annotations only cover a subset of the fluent API functionality, so there