实体框架:无法评估表达式,因为当前方法的代码已经过优化。

时间:2015-04-13 03:42:17

标签: vb.net entity-framework

我正在使用Entity framework 6(DBContext)和VB.net 2013 我有这段代码:

Partial Public Class Myentities
Inherits DbContext
Implements IObjectContextAdapter
Public ReadOnly Property ObjectContext() As ObjectContext Implements IObjectContextAdapter.ObjectContext
    Get
        Dim objectContext__1 = TryCast(Me, IObjectContextAdapter)
        If objectContext__1 IsNot Nothing Then
            Return TryCast(Me, IObjectContextAdapter).ObjectContext
        Else
            Return Nothing
        End If
    End Get
End Property

  Public Sub New(connectionString As String)
    MyBase.New("name=MyEntities")
    Database.Connection.ConnectionString = connectionString
End Sub
End class

.......

dim context as new Myentities

但是我收到了这个错误:

Cannot evaluate expression because the code of the current method is optimized. 

有什么问题?

谢谢!

0 个答案:

没有答案