商信互联
本主题列出了使用在XAF的Entity Framework Designer(模型优先方法)中创建的Entity Framework数据模型的细节。如果您在代码中创建实体(“代码优先”),请跳过本主题。
在“模型优先”方法中,当您通过XafApplication.ConnectionString属性或配置文件中的ConnectionString属性指定连接时,DbContext后代中需要带有connectionString参数的构造函数(请参阅使用实体框架数据模型)。通过创建补充您的DbContext / ObjectContext后代的局部类来添加此构造函数。
public partial class MySolutionModelContainer : DbContext {
public MySolutionModelContainer(string connectionString) : base(connectionString) { }
}
Partial Public Class MySolutionModelContainer
Inherits DbContext
Public Sub New(ByVal connectionString As String)
MyBase.New(connectionString)
End Sub
End Class