5

I have an existing SQLite database that I want to use in Entity Framework. However SQLite's weird type system means you can even

create table temp(temp datetime);
insert into temp values ('whatever');

The dates are stored as Unix time integers. My model classes are autogenerated by Visual Studio, so how do I tell the code generator to handle these dates correctly and not make the application throw

String was not recognized as a valid DateTime.

exceptions on startup?

1 Answer 1

6

You have to change your connection string to something like

data source="|DataDirectory|\data.sqlite";datetimeformat=UnixEpoch;datetimekind=Utc

You can change these settings in Server Explorer/<right click your connection>/Modify Connection/Advanced, but changing the settings there will not propagate to your App.config connection string.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.