我正在使用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.
有什么问题?
谢谢!