Git Product home page Git Product logo

Comments (7)

msallin avatar msallin commented on June 15, 2024

I've several Questions.
MinLength: This is done by something like this nvarchar(x, y). Just one parameter means "max" but which is "min" and which is "max" if you use two?

DatabaseGenerated: I assume you are talking about this DatabaseGenerated(DatabaseGeneratedOption.Computed) right? If yes, how should it behave (with other word, how should it be reflected in the generated SQLite DDL)?

Timestamp: This should do this ColumnName DATETIME DEFAULT (CURRENT_TIMESTAMP) right?

NotMapped: If I annotate a property with [NotMapped] its not created. What should be implemented?

from sqlitecodefirst.

code1line avatar code1line commented on June 15, 2024

You are right, I've tested all this annotations...

NotMapped: Is working.

MinLength: Is working too (does nothing, but you can use it with MVC).

DatabaseGenerated: Is working (None and Identity). I was only a little bit confused, that Identity is obviously the implicit mode. With Computed you get an error and the suggestion to use Identity. - This is ok.

from sqlitecodefirst.

code1line avatar code1line commented on June 15, 2024

Timestamp: Is not working...

It is not about a date. To explain: We are using SQL Server and also SQLite. If you use something like this
[Timestamp]
public byte[] Timestamp { get; set; }
you get a correct Timestamp-column on SQL Server, but a crash (no db-generation) on SQLite. I don't know how we can solve this. Maybe ignoring on SQLite?

from sqlitecodefirst.

msallin avatar msallin commented on June 15, 2024

NotMapped: Will add it to the supported list

DatabaseGenerated: Will add it to the supported list

MinLength: Yes currently is just ignored and it will also not have any meaning if its added because SQLite will just ignore max and min. But as "max" is supported "min" should also be supported (it has no impact to the behavoir but if you have a look at the database, its there, for documentation, which is a good thing). Here my problem is that I don't find anything about the min/max stuff. Do you know what is min and max if I have a SQLite Command like this "NVARCHAR(x, y)"?

Timestamp: The problem with this is that, as soon as I add the "Timestamp" annotation to a property, my Initializer don't get called. I have no idea why.. So it does not crash because of my code. If the initializer would be called and it does not know an annotation, this annotation is just ignored.

from sqlitecodefirst.

code1line avatar code1line commented on June 15, 2024

MinLength: I think it is only useful for validation in MVC. In my opinion it makes no sense to have such a constraint in the database. This "idea" is really new to me...

Timestamp: You are absolutely right, it is ignored. I also have no idea why...

from sqlitecodefirst.

msallin avatar msallin commented on June 15, 2024

The cause of the "Timestamp" problem is the TimestampAttributeConvention as a workaround you can use modelBuilder.Conventions.Remove<TimestampAttributeConvention>(); on the OnModelCreating method from the DbContext. Of course, in your case, you need to dedect which Db is used (SQL-Server or SQLite).

Here is what this convention does.
public override void Apply(ConventionPrimitivePropertyConfiguration configuration, TimestampAttribute attribute) { Check.NotNull<ConventionPrimitivePropertyConfiguration>(configuration, "configuration"); Check.NotNull<TimestampAttribute>(attribute, "attribute"); configuration.IsRowVersion(); }

Where IsRowVersion will do the following:
/// <summary> /// Configures the property to be a row version in the database. /// The actual data type will vary depending on the database provider being used. /// Setting the property to be a row version will automatically configure it to be an /// optimistic concurrency token. /// /// </summary> /// /// <returns> /// The same <see cref="T:System.Data.Entity.ModelConfiguration.Configuration.ConventionPrimitivePropertyConfiguration"/> instance so that multiple calls can be chained. /// /// </returns> /// /// <remarks> /// Calling this will have no effect once it has been configured. /// This method throws if the property is not a <see cref="T:Byte[]"/>. /// /// </remarks> public virtual ConventionPrimitivePropertyConfiguration IsRowVersion() { if (this._configuration() != null) { if (this._binaryConfiguration.Value == null) throw new InvalidOperationException(Strings.LightweightPrimitivePropertyConfiguration_IsRowVersionNonBinary((object) this._propertyInfo.Name)); if (!this._binaryConfiguration.Value.IsRowVersion.HasValue) this._binaryConfiguration.Value.IsRowVersion = new bool?(true); } return this; }

The comment says "The actual data type will vary depending on the database provider being used.".
So without further investigation I assume that the SQLite provider does not play well with the "IsRowVersion " configuration.

Additional what we can do is to remove the Convention in the SQLiteContextInitializert. This means the "Timestamp" attribute will just be ignored.

from sqlitecodefirst.

msallin avatar msallin commented on June 15, 2024

4d733a2

from sqlitecodefirst.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.