加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 建议在开发期间使用nhibernate设置种子数据(不是

发布时间:2020-12-16 04:26:34 所属栏目:asp.Net 来源:网络整理
导读:在开发nhibernate Web应用程序时应如何设置种子数据? (这是Mvc) 我应该创建一个方法并在应用程序加载期间(当它是调试模式时)触发它,并在我不需要它时简单地将它注释掉吗? 或者,还有更好的方法? 解决方法 我建议看看像 AutoPoco这样的东西. AutoPoco repla
在开发nhibernate Web应用程序时应如何设置种子数据? (这是Mvc)

我应该创建一个方法并在应用程序加载期间(当它是调试模式时)触发它,并在我不需要它时简单地将它注释掉吗?

或者,还有更好的方法?

解决方法

我建议看看像 AutoPoco这样的东西.

AutoPoco replaces manually written object mothers/test data builders
with a fluent interface and an easy way to generate a large amount of
readable test data. By default,no manual set-up is required,
conventions can then be written against the names/types of property or
manual configuration can be used against specific objects.

The primary use cases are

  • Creating single,valid objects for unit tests in a standard manner across all tests
  • Creating large amounts of valid test data for database population

这与NHibernate没有直接关系 – 理论上你可以将它与任何可以持久保存POCO的数据层结合起来.

我会避免将代码添加到Application_Start中 – 这听起来像是意外地破坏生产数据库的一个秘诀.您最好创建一个简单的控制台应用程序,只要您想重新设置数据库,就可以运行它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读