天天看点

System.InvalidOperationException: The type MyContext+Northwind was not mapped.

System.InvalidOperationException: The type MyContext+Northwind was not mapped. Check that the type has not been explicitly excluded by using the Ignore method or NotMappedAttribute data annotation. Verify that the type was defined as a class, is not primitive, nested or generic, and does not inherit from EntityObject.

错误原因:

 entity framework不能将内部类与数据库匹配。

错误代码如下所示:

System.InvalidOperationException: The type MyContext+Northwind was not mapped.
System.InvalidOperationException: The type MyContext+Northwind was not mapped.

解决的办法:Northwind作为内部类。正确的代码如下所示

System.InvalidOperationException: The type MyContext+Northwind was not mapped.
System.InvalidOperationException: The type MyContext+Northwind was not mapped.

 本文转自陈哈哈博客园博客,原文链接http://www.cnblogs.com/kissazi2/archive/2013/01/04/2843944.html如需转载请自行联系原作者

kissazi2