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()

有帮助吗?

解决方案

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:

[<Generate>]
type Northwind = TypeProviders.SqlDataConnection
  <"data source=.\\sqlexpress;initial catalog=Northwind;integrated security=True">

[<Generate>]
type Northwind = TypeProviders.SqlDataConnection
  <"data source=.\\sqlexpress;initial catalog=Northwind;integrated security= True">

//                                                                          ^ here

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top