The mapping of CLR type to EDM type is ambiguous with EF 6 & 5?

后端 未结 14 1565
长发绾君心
长发绾君心 2020-11-27 05:38

Please any one can help me to fix this error?

Schema specified is not valid. Errors:

The mapping of CLR type to EDM type is ambiguous because mult

相关标签:
14条回答
  • 2020-11-27 06:31

    Just add the EntityFramework as "Code First from database" and not as "EF Designer from database". This resolved my problem, but it has a dark side, if you change your database you have to remove all the classes and add it again, or just edit the classes, I use the last when I change properties of the columns, like "Allows null" or the size of a string. But if you add columns I recomend remove and add again the classes.

    0 讨论(0)
  • 2020-11-27 06:31

    There is a library called AutoMapper which you can download. It helps you to define class mappings from one type to another.

    Mapper.CreateMap<Model.FileHistoryEFModel, DataTypes.FileHistory>();
    Mapper.CreateMap<DataTypes.FileHistory, Model.FileHistoryEFModel>();
    
    0 讨论(0)
提交回复
热议问题