Tag: 代码 首先

entity frameworkCTP 4 – 代码第一个自定义数据库初始化程序

我想实现一个自定义的数据库初始化策略,以便我可以生成数据库模式并使用提供的用户ID和密码将其应用到EXISTING EMPTY SQL数据库。 不幸的是内置的策略不提供我在找什么: // The default strategy creates the DB only if it doesn't exist – but it does // exist so this does nothing Database.SetInitializer(new CreateDatabaseOnlyIfNotExists<DataContext>()); // Drops and re-creates the database but then this breaks my security mapping and // only works if using a “Trusted" connection Database.SetInitializer(new RecreateDatabaseIfModelChanges<DataContext>()); // Strategy for […]