Questo è il codice im utilizzando per configurare il database:Come faccio a disattivare caricamento pigro, Entity Framework 4.1 utilizzando codice Migrazioni Configurazione
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);
}
Se qualcuno sa come fare questo, per favore fatemelo sapere. Ho anche provato proprietà non virtuali sulle classi del modello, ma questo sembra non fare alcuna differenza.
Sì, ho già provato questo metodo, funziona correttamente senza il primo codice di migrazione. Quindi penso che abbia qualcosa a che fare con questo, perché non funziona ... – woz