Hi I'm try to use EF with a code first workflow against an existing database but I am getting the error:
{"Value cannot be null. Parameter name: source"}
when using the following line:
Dim ctx = New MVCTest1
Dim t = ctx.Companies.ToList()
My POCO classes are included below:
I have a standard conn string called MVCTest1 which points at SQL Server. I think EF is using that as I can see it in connection string of the dbContext. Does the conn string need to be in a special format. I also noticed the onmodelcreated isn't being called. I'm not sure if that's relevant. Very new to this so I suspect it's something obvious Cheers, Chris
Imports System.Data.Entity
Public Class Company
Public CompanyID As Integer
Public CompanyName As String
Public Overridable Property Contacts As ICollection(Of Contact)
End Class
Public Class Contact
Public ContactID As Integer
Public FirstName As String
Public LastName As String
Public Overridable Property Company As Company
End Class
Public Class MVCTest1
Inherits DbContext
Public Contacts As DbSet(Of Contact)
Public Companies As DbSet(Of Company)
Protected Overrides Sub OnModelCreating(ByVal modelBuilder As System.Data.Entity.DbModelBuilder)
---Not being called
End Sub
End Class