を使用して、Entity Frameworkの4.1を遅延ロードを無効にしてください:は、どのように私はこれは、データベースを構成するために使用してコードイムあるコードの移行設定
internal sealed class Configuration : DbMigrationsConfiguration<DataStore>
{
public Configuration()
{
AutomaticMigrationsEnabled = true;
SetSqlGenerator("System.Data.SqlServerCe.4.0", new SqlCeModelColumnBugWorkaroundProvider());
}
protected override void OnSeed(DbContext context)
{
context.Configuration.LazyLoadingEnabled = false;
new SeedData(context as DataStore);
}
public static void DoDatabaseInitialisation()
{
var setting = ConfigurationManager.AppSettings["RequiresDbUpdate"];
var requiresDbUpdate = bool.Parse(string.IsNullOrEmpty(setting) ? "false" : setting);
if (! requiresDbUpdate) return;
//otherwise create/update the database
var dbMigrator = new DbMigrator(new Configuration());
dbMigrator.Update();
ResetDbUpdateRequired("/");
}
private static void ResetDbUpdateRequired(string appPath)
{
var hostName = WebHelper.GetHost(false);
if (!hostName.Contains("localhost"))
WebHelper.UpdateWebConfigAppSetting("RequiresDbUpdate", "false", appPath);
}
誰もがこれを行う方法を知っている場合、私に知らせてください。私はまた、モデルクラスで非仮想プロパティを試しましたが、これはまったく違いがないようです。私はいつもDbContextの方法を使用する前にそれを呼び出す
context.Configuration.LazyLoadingEnabled = false;
を使用しました
ええ、私はすでにこのメソッドを試してみました。だから私はそれがなぜそれが機能していないのかと関係があると思います... – woz