Entity Framework creates empty migration but insists that my model is different

后端 未结 2 910
伪装坚强ぢ
伪装坚强ぢ 2021-01-12 08:56

Today is a sad day. First thing today I saw EF exception saying that \"The model backing the \'DomainContext\' context has changed since the database was created.\"

2条回答
  •  借酒劲吻你
    2021-01-12 09:53

    The cause to my problem was a [AllowHtml] attribute applied to one of the models. The trouble started to happen after I've updated MVC to 5.1.1 and WebApi to 2.1.

    I've removed that attribute from EF-Model and stripped and re-build the database and the problem was gone.

    I've written up a blog post on how to debug this kind of problems: http://tech.trailmax.info/2014/03/inside_of_ef_migrations/

    Also I think this [AllowHtml] attribute is a bug, I'll create a reproducible solution and will submit the bug report to EF-people.

    Update: I actually could never reproduce the error. [AllowHtml] attribute on class properties had nothing to do with it. A magical glitch that was.

提交回复
热议问题