fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
572 stars 146 forks source link

Mappers not working anymore when using ContextSchemaPath #594

Closed tforkmann closed 5 years ago

tforkmann commented 5 years ago

Description

Trying to deploy my project to Azure DevOps. I ran into following issue: Once I used the ContextSchemaPath in Offline mode the mapping functions stop working. The dbRecords don't contain the Table elements any more.

Repro steps

  1. Define mappers like described here: https://github.com/fsprojects/SQLProvider/blob/master/docs/content/core/mappers.fsx

  2. Save ContextSchema

  3. Add ContextSchema path to the type definition like that type sql = SqlDataProvider<Common.DatabaseProviderTypes.SQLITE, connectionString, ResolutionPath = resolutionPath, CaseSensitivityChange = Common.CaseSensitivityChange.ORIGINAL, ContextSchemaPath = ContextSchemaPath>

  4. DbRecords are failing because table entitys are not containing the table elements Following Line would crash: https://github.com/fsprojects/SQLProvider/blob/master/docs/content/core/mappers.fsx#L39

Expected behavior

DbRecords should work also in Offline Mode.

Example

image

Any help would be appreciated!

tforkmann commented 5 years ago

Same thing with the entities in the query definitions: image

Thorium commented 5 years ago

Are you using dbContect in the same project? I think offline save is not happening across multiple projects.

Thorium commented 5 years ago

What version of SQLProvider you use? If you upgrade from earlier than 1.1.49 you may have to re-save the schema path because stored procedures were added to the schema.

This is not duplicate of #552 , right?

tforkmann commented 5 years ago

I only have one project. And I’m using version 1.1.57. I’m not using stored procedures just normal table mappers. I guess the entities are not save locally?

Thorium commented 5 years ago

Only the entity shapes that are used are saved. Not the shape of the whole database.

tforkmann commented 5 years ago

Ok,

the table is being used and saved in the sql.schema.

image

But there is no entities of the dbRecord saved.

Is it possible to save those information?

Thorium commented 5 years ago

It should save all the entity columns in use (at the time of saving), so you can compile the source code off-line without the database.

It won't save the columns not-in-use, so you can't develop off-line. (You can use the already used columns, but not any new columns.)

So it's kind of a lazy-save. Should work in CI, and when your internet is temporarily down. Is this what you expect, or something else?

Thorium commented 5 years ago

Once saved and path added, it's off-line. To re-save, remove the path and save again. I don't know if the editor has to be restarted.

tforkmann commented 5 years ago

Thank you soo much!

I found my mistake! I didn't saved the context at the end of compile time.

I added the saveContextSchema() at the end of my project and it now works with CI!