F# 类型提供程序和持续集成,第 2 部分 [英] F# Type Providers and Continuous Integration, Part 2

查看:48
本文介绍了F# 类型提供程序和持续集成,第 2 部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我之前关于 F# 类型提供程序和持续集成.

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

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. 配置文件的名称(以及位置)在编译时与运行时不同,例如app.config -> MyApp.exe.config,如果尝试使用会导致运行时错误

  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">

(实际上,没有必要指定 ConfigFile="app.config",因为它是默认值.)

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

可以通过将 app.config 文件复制到输出目录来避免运行时错误(有一个设置),但这会导致输出中同时包含 app.config 和 MyApp.exe.config 文件目录.不是很漂亮.为类型提供程序添加单独的配置文件是另一种解决方案,但恕我直言,这也不是很漂亮.

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?

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

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.

问题:您如何以最方便的方式解决这个问题?请记住,解决方案必须是 CI 流程的工作部分!

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!

此策略需要在构建服务器上的每个构建中生成数据库,可能来自带有一些功能/冲刺更新脚本的基线脚本.

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?

推荐答案

在运行时,您可以使用接受连接字符串的 GetDataContext 重载.请参阅此处:向 Linq-To 提供连接字符串-Sql 数据提供者

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# 类型提供程序和持续集成,第 2 部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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