类型提供者:如何重新生成?
您将如何创建LINQ-TO-SQL
类型提供程序、生成或/和重新生成类?
我刚刚向数据库添加了一个新表,但类型提供程序无法弄清楚这一点。我尝试删除带有类型提供程序的行,然后再次输入 - 没有成功。我也尝试过重建..仍然没有运气。
编辑:
我已经定义了类型提供程序,例如:
[<Generate>]
type dbSchema = SqlDataConnection<"conString">
并使用它,例如:
let ctx = dbSchema.GetDataContext()
How would you make the LINQ-TO-SQL
type provider, generate or/and regenerate the classes?
I've just added a new table to my database, and the type provider can't figure that out. I've tried to delete the line with the type provider, and type it once more - no luck. I've also tried to do a rebuild.. still no luck.
Edit:
I've defined the type provider like:
[<Generate>]
type dbSchema = SqlDataConnection<"conString">
and using it like:
let ctx = dbSchema.GetDataContext()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是对的——这似乎很棘手。我在脚本文件中使用
SqlDataConnection
类型提供程序,到目前为止我发现的更新架构的唯一方法是在连接字符串中进行一些较小的(不相关的)更改。例如,在参数之一的=
之后添加空格:该架构似乎是使用连接字符串作为键进行缓存的,因此如果您将其更改回来,您将再次获得旧架构。我想这可能是一个错误,因此添加空格是一种可能的解决方法。
还有一个参数
ForceUpdate
,但这似乎没有任何效果,并且文档对此没有说太多。You're right - this seems to be quite tricky. I'm using
SqlDataConnection
type provider in a script file and the only way to update the schema that I've found so far is to make some minor (irrelevant) change in the connection string. For example, add space after=
of one of the parameters:The schema seems to be cached using connection string as the key, so if you change it back, you get the old schema again. I guess this is probably a bug, so adding whitespace is a possible workaround.
There is also a parameter
ForceUpdate
, but that doesn't seem to have any effect and the documentation doesn't say much about it.