Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type provider: How to regenerate?

Tags:

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

like image 992
ebb Avatar asked Oct 19 '11 12:10

ebb


1 Answers

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.

like image 198
Tomas Petricek Avatar answered Sep 18 '22 08:09

Tomas Petricek