F#Type Providers and Continuous Integration,第2部分 [英] F# Type Providers and Continuous Integration, Part 2

查看:200
本文介绍了F#Type Providers and Continuous Integration,第2部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个(实际上是几个)后续问题到我以前的问题在 F#Type Providers and Continuous Integration



在我看来,最好使用 SqlDataConnection 类型提供程序作为编译时检查代码/数据库完整性在功能分支驱动开发中保持完整;您将知道在每次提交/构建时,尚未对尚未应用于数据库的代码进行任何更改,假设构建数据库也是CI过程的一部分。



但是,出现了一些问题:


  1. 配置文件在编译时与运行时不同,例如app.config - > MyApp.exe.config,如果您尝试使用

    会导致运行时错误。

      SqlDataConnection< ConnectionStringName =DbConnection,ConfigFile =app.config> 

    (实际上,指定 ConfigFile =app.config不是必需的,因为它是默认值。)



    运行时错误可以通过将app.config文件复制到输出目录设置),但这将导致在输出目录中同时具有app.config和MyApp.exe.config文件。不是很漂亮。为类型提供程序添加单独的配置文件将是另一个解决方案,但是这不是很漂亮。



    问题:一个更优雅的解决方案这个问题?


  2. 下一个问题出现时,你来到构建服务器。很可能你不想像开发时那样对同一个数据库进行编译,因此需要一个不同的连接字符串。是的,在生产中你需要另一个。



    问题:如何以最方便的方式解决这个问题?


  3. 这个策略需要在构建服务器上生成每个构建的数据库,可能是从

    问题:有人试过这个,它是如何影响构建时间的?如果是,您是如何创建此步骤的?



解决方案

可以使用接受连接字符串的 GetDataContext 重载。请参阅:提供连接字符串到Linq-To -Sql数据提供程序


This is a (actually it is several) follow-up question to my previous question on F# Type Providers and Continuous Integration.

It seems to me that it would be a good idea to use the SqlDataConnection type provider as a compile-time check that the code/database integrity remains intact in feature-branch driven development; you would know at every commit/build that no changes have been made to the code that has not also been applied to the database, assuming that building the database is also a part of your CI process.

However, a couple of questions arise:

  1. The name (as well as the location) of the config file is not the same at compile time as at runtime, e.g. app.config -> MyApp.exe.config, which will result in a runtime error if you try to use

    SqlDataConnection<ConnectionStringName="DbConnection", ConfigFile="app.config">
    

    (Actually, specifying ConfigFile="app.config" is not necessary, since it is the default value.)

    The runtime error can be avoided by copying the app.config file to the output directory (there’s a setting for that), but that would result in having both an app.config and a MyApp.exe.config file in the output directory. Not very pretty. Adding a separate configuration file for type providers would be another solution, but imho that’s not very pretty either.

    Question: Has anyone come up with a more elegant solution to this problem?

  2. The next problem arises when you come to the build server. It is most likely that you don’t want to compile against the same database as you did while developing, thus requiring a different connection string. And yes, in production you’d need yet another one.

    Question: How do you go about solving this in the most convenient way? Remember, the solution has to be a working part of a CI process!

  3. This strategy would require generating the database on each build at the build server, probably from a baseline script with some feature/sprint update scripts.

    Question: Has anyone tried this and how did it affect build times? If yes, how did you create this step?

解决方案

At runtime you can use the GetDataContext overload that accepts a connection string. See here: Providing connection string to Linq-To-Sql data provider

这篇关于F#Type Providers and Continuous Integration,第2部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆