I have seen some code sample that put an entity framework connection string as a constructor argument when creating a new DbContext. But when I added a new ADO.NET entity data model into a project (database first), the DbContext only has one parameterless constructor.
Did I miss a step? What should I do to get that constructor?
Visual Studio 2012 targeting .net framework 4.5 entity framework 5.
As per Arthur Vickers' suggestion, I am extending the partial class to have a constructor that accepts connection string. In C# (very similar to hege's answer):
public partial class MyEFEntities
{
public MyEFEntities(string connectionstring)
: base(connectionstring)
{
}
}
Or in VB.Net:
Partial Public Class MyEFEntities
Public Sub New(ConnectionString As String)
MyBase.New(ConnectionString)
End Sub
End Class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With