Postgresql, timestamp and EF
Posted: Tue 09 Jun 2015 13:49
I've noticed that EF does not seem to handle the precision of a PostgreSQL timestamp. If you have a 'timestamp(x) with time zone' (where x is 0 to 6) this is imported as a 'timestamp with time zone'. This does cause some issues when the field is marked as concurrency mode, but the main issue is when we use the 'create script from model' option, it returns the wrong type of timestamp. A simple test database follows:
Regards, Damon.
Code: Select all
CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'LATIN1' LC_COLLATE = 'C' LC_CTYPE = 'C';
Code: Select all
-- Dumped from database version 9.3.5
ALTER DATABASE test OWNER TO postgres;
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'LATIN1';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
CREATE DATABASE test WITH TEMPLATE = template0 ENCODING = 'LATIN1' LC_COLLATE = 'C' LC_CTYPE = 'C';
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE atable (
column1 timestamp with time zone,
column2 timestamp(0) with time zone
);
ALTER TABLE public.atable OWNER TO postgres;
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;