C# 使用VB.NET找不到AddOrUpdate()方法?
我正在尝试将C代码转换为VB代码: 在C#代码中,它可以调用AddOrUpdate方法,但当我在VB中编写它时,在intellisense中找不到它 c#代码:C# 使用VB.NET找不到AddOrUpdate()方法?,c#,vb.net,iqueryable,C#,Vb.net,Iqueryable,我正在尝试将C代码转换为VB代码: 在C#代码中,它可以调用AddOrUpdate方法,但当我在VB中编写它时,在intellisense中找不到它 c#代码: protected override void Seed(eManager.Web.Infrastructure.DepartmentDB context){ context.Departments.AddOrUpdate( d => d.Name, new Departm
protected override void Seed(eManager.Web.Infrastructure.DepartmentDB context){
context.Departments.AddOrUpdate( d => d.Name,
new Department() { Name = "Engineering"},
new Department() { Name = "Sales"}
);
}
VB代码:
protected override void Seed(eManager.Web.Infrastructure.DepartmentDB context){
context.Departments.AddOrUpdate( d => d.Name,
new Department() { Name = "Engineering"},
new Department() { Name = "Sales"}
);
}
但是当我在VB中编写AddOrUpdate()方法时,我找不到它。DepartmentDB类的声明如下:
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports System.Threading.Tasks
Imports System.Data.Entity
Imports eManager.Domain
Public Class DepartmentDB
Inherits DbContext
Implements IDepartmentDataSource
Private _DBEmployees As DbSet(Of Employee)
Private _DBDepartments As DbSet(Of Department)
Public ReadOnly Property Departments As IQueryable(Of Department) Implements IDepartmentDataSource.Departments
Get
Return _DBDepartments
End Get
End Property
Public ReadOnly Property Employees As IQueryable(Of Employee) Implements IDepartmentDataSource.Employees
Get
Return _DBEmployees
End Get
End Property
End Class
我想你失踪了
Imports System.Data.Entity.Migrations
由于AddOrUpdate()是一个扩展方法:
在我看来,您的库或解决方案的另一部分似乎没有构建,这只是其中的一个症状。@DominicKexel,您已经了解了一些内容,
Import
可能不存在;它在什么名称空间中?