在app start上生成迁移 - 首先是代码

时间:2017-07-12 09:34:36

标签: asp.net entity-framework asp.net-mvc-5

在我的开发环境中,我希望我的数据库会自动更新,以匹配每个应用程序启动时更新的代码第一个模型。 在我的生产环境中显然不是这种情况,但我希望至少尝试在本地设置它。

此时我已经设置了#34;自动迁移"但要实现这一点,我必须在NuGet控制台中手动执行update-database。 我希望每次调用Application_Start()

时都能自动执行此命令

这可能吗?如果没有,为什么?如果是,我该如何实现呢?

1 个答案:

答案 0 :(得分:1)

你应该使用它:

MyConfiguration

在Controller构造函数中internal sealed class MyConfiguration : DbMigrationsConfiguration<MigrationDbContext> { public MyConfiguration() { AutomaticMigrationsEnabled = true; } } 为:

<bean id="WSS4JOutInterceptor" class="sk.posam.risng.soa.mur.interceptor.security.WSS4JOutInterceptorCustom">
    <argument>
        <map>
            <entry key="action" value="Signature"/>
            <entry key="user" value="posam_ssl"/>
            <entry key="signatureKeyIdentifier" value="DirectReference"/>
            <entry key="passwordCallbackRef">
                <ref component-id="passwordCallback"/>
            </entry>
            <!--tato property musi byt vyplnena inak sa nepusti podpisovanie sprav, avsak property su ulozene v cryptoHolder-->
            <entry key="signaturePropFile" value="seeCryptoHolder.properties"/>
        </map>
    </argument>
    <property name="securityEnabled" value="${security.enabled}"/>
    <property name="cryptoHolder" ref="cryptoHolder"/>
</bean>
相关问题