我有一个C#项目,我正在使用Entity Framework 6.1。我有一些迁移文件和同一文件夹中的Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
#If VBA7 Then
Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As LongLong, ByVal dwExtraInfo As LongPtr)
#Else
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
#End If
Private Const VK_SNAPSHOT As Byte = 44
Public Function StoreScreenShotFrom_As(URL_Dest As String, Img_Name As String, Img_Type As String)
Dim IE As Object, IECaption As String
Dim aXL As Object, aWB As Object, aSh As Object, aChO As Object, Img_Path As String
Img_Path = VBA.Environ$("temp") & "\" & Img_Name & "." & Img_Type
Set IE = CreateObject("InternetExplorer.Application")
With IE
.Visible = True
.FullScreen = True
.Navigate URL_Dest
'''Possibilities to wait until the page is loaded
'Do While .Busy Or .readyState <> 4
' DoEvents
'Loop
'''OR
'Sleep 5000
'''OR (custom sub below)
WasteTime 5
'''Take a snapshot
Call keybd_event(VK_SNAPSHOT, 0, 0, 0)
DoEvents
.Quit
End With 'IE
'''Start Excel
Set aXL = CreateObject("Excel.Application")
On Error Resume Next
With aXL
.WindowState = -4143 'xlNormal
.Top = 1
.Left = 1
.Height = .UsableHeight
.Width = .UsableWidth
.WindowState = -4137 'xlMaximized
On Error GoTo 0
Set aWB = .Workbooks.Add
Set aSh = aWB.Sheets(1)
Set aChO = aSh.ChartObjects.Add(0, 0, .Width, .Height)
End With 'aXL
With aChO
.Activate
.Chart.Paste
With .ShapeRange
.Line.Visible = msoFalse
.Fill.Visible = msoFalse
End With '.ShapeRange
With .Chart
.Export FileName:=Img_Path, Filtername:=Img_Type, Interactive:=False
End With '.Chart
DoEvents
.Delete
End With 'oChrtO
aWB.Close False
DoEvents
aXL.Quit
StoreScreenShotFrom_As = Img_Path
End Function
Private Sub WasteTime(SecondsToWait As Long)
Dim TimeLater As Date
TimeLater = DateAdd("s", SecondsToWait, Now)
Do While Now < TimeLater
DoEvents
Loop
End Sub
文件。 Configuration.cs
包含以下类:
Configuration.cs
如果我正确理解了Entity Framework,那么应该在应用新的数据库迁移文件后执行namespace SNS.Database.Migrations
{
public class Configuration : DbMigrationsConfiguration<SNSContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(SNSContext context)
{
...
}
}
}
方法。此外,要进行配置,请通过以下调用完成:
Seed
工作正常。但是,即使我没有进行System.Data.Entity.Database.SetInitializer(new MigrateDatabaseToLatestVersion<SNSContext, Configuration>());
调用,也始终会调用Seed
方法。
所以我的问题是,是什么告诉实体框架运行SetInitializer
,为什么它总是执行Configuration.cs
方法?
我已经检查了我的Seed
文件,但没有指定codeConfigurationType。