0

On an already in place table in the database we are trying to Add a column for the CreationDate

mapping.Map(x => x.CreationDate)
            .Not.Nullable()
            .Default("to_date('01-01-0001','dd-MM-yyyy')")

This works perfectly fine with oracle but SQLite will not understand this, which is perfectly normal because it does not know the to_date() function.

If i use

DateTime.MinValue.ToString()

for the Default value with or without an specific format. Then it will work in SQLite but it wont work in Oracle.

Does someone know a solution to solve this.

1 Answer 1

1

leave out the defaultvalue and write a convention

class CreationDateConvention  : IPropertyConvention
{
    public CreationDateConvention(string default)
    {
        _default = default;
    }

    public void Apply(... instance)
    {
        if (instance.Name == "CreationDate")
            instance.Default(_default)
    }
}


// and while configuring
...FluentMappings.AddFromAssemblyOf<>().Conventions.Add(new CreationDateConvention(isOracle ? "to_date..." : Datetime.Minvalue.ToString())
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.