System.Data.SQLite.EF6 feature request: Timespan support

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

System.Data.SQLite.EF6 feature request: Timespan support

Barry Smith
A project I work on runs mainly on SQL Server, but there are times we want
to be able to create the same data model in SQLite for portability.

We mostly use EF6 to access the database; we have a code-first approach and
write custom scripts to generate the database schema.

We have a custom ConnectionFactory to determine whether a new database
context should use a SQLiteConnection or SQLServerConnection. (Yes it's
deprecated but it works...)

This was working well until we added a TimeSpan field to one of our
entities. Now we get an exception on model creation: There is no store type
corresponding to the EDM type 'Edm.Time' of primitive type 'Time'.

I know it would be possible for us to store the Ticks or TotalSeconds of
the TimeSpan in a SQLite INTEGER or REAL field, but we've already got
deployments using the TimeSpan field on SQLServer and would rather avoid
having to change that schema.

Would it be possible for a future version of SQLite to support TimeSpan
mapping in the entity framework?

Thanks in advance,

 - Barry Smith
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: System.Data.SQLite.EF6 feature request: Timespan support

Simon Slavin-3
On 20 Aug 2019, at 12:19am, Barry <[hidden email]> wrote:

> Would it be possible for a future version of SQLite to support TimeSpan mapping in the entity framework?

This is not an aspect of SQLite itself, but of how Entity Framework 6 talks to SQLite.  The development team who could affect this change are those who maintain Entity Framework.  Perhaps you could contact them.

I'm not an expert on it, but I see no reason why Entity Framework could not see a '.Time' and know that SQLite should store it as text or a number, making appropriate conversions when needed.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: System.Data.SQLite.EF6 feature request: Timespan support

Barry Smith
Hi Simon,

The System.Data.SQLite (basically a dotNet wrapper for SQLite, and official
part of SQLite) team maintain a library called System.Data.SQLite.EF6,
which I understand to be the glue between the Entity Framework and SQLite.
If my understanding is correct, this is the library that should be doing
the TimeSpan <-> (Number or string or however you want to store it in the
database) conversion.

Cheers,

 - Barry

On Mon, 19 Aug 2019 at 16:40, Simon Slavin <[hidden email]> wrote:

> On 20 Aug 2019, at 12:19am, Barry <[hidden email]> wrote:
>
> > Would it be possible for a future version of SQLite to support TimeSpan
> mapping in the entity framework?
>
> This is not an aspect of SQLite itself, but of how Entity Framework 6
> talks to SQLite.  The development team who could affect this change are
> those who maintain Entity Framework.  Perhaps you could contact them.
>
> I'm not an expert on it, but I see no reason why Entity Framework could
> not see a '.Time' and know that SQLite should store it as text or a number,
> making appropriate conversions when needed.
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|

Re: System.Data.SQLite.EF6 feature request: Timespan support

Joe Mistachkin-3
In reply to this post by Barry Smith

I’ll look into adding this type mapping to System.Data.SQLite.

Sent from my iPhone

> On Aug 19, 2019, at 7:19 PM, Barry <[hidden email]> wrote:
>
> A project I work on runs mainly on SQL Server, but there are times we want
> to be able to create the same data model in SQLite for portability.
>
> We mostly use EF6 to access the database; we have a code-first approach and
> write custom scripts to generate the database schema.
>
> We have a custom ConnectionFactory to determine whether a new database
> context should use a SQLiteConnection or SQLServerConnection. (Yes it's
> deprecated but it works...)
>
> This was working well until we added a TimeSpan field to one of our
> entities. Now we get an exception on model creation: There is no store type
> corresponding to the EDM type 'Edm.Time' of primitive type 'Time'.
>
> I know it would be possible for us to store the Ticks or TotalSeconds of
> the TimeSpan in a SQLite INTEGER or REAL field, but we've already got
> deployments using the TimeSpan field on SQLServer and would rather avoid
> having to change that schema.
>
> Would it be possible for a future version of SQLite to support TimeSpan
> mapping in the entity framework?
>
> Thanks in advance,
>
> - Barry Smith
> _______________________________________________
> sqlite-users mailing list
> [hidden email]
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users