SQLite NOT NULL constraint failed
up vote
0
down vote
favorite
EF DB first approach. During an insert the exception: "SQLite NOT NULL constraint failed (XX)" occurs. However, no exception will be thrown if I use the SqlClient provider against a MSSQL DB.
Table:
- XY, PK, FK, int not null
- XX, PK, int not null
Model-Configuration
ToTable("Table");
Property(on => on.XX)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XX")
.IsRequired();
HasKey(on => on.XX);
Property(on => on.XY)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XY")
.IsRequired();
EDIT: XY is set in the model before .SaveChanges(); XX on the other hand is AI.
entity-framework sqlite
add a comment |
up vote
0
down vote
favorite
EF DB first approach. During an insert the exception: "SQLite NOT NULL constraint failed (XX)" occurs. However, no exception will be thrown if I use the SqlClient provider against a MSSQL DB.
Table:
- XY, PK, FK, int not null
- XX, PK, int not null
Model-Configuration
ToTable("Table");
Property(on => on.XX)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XX")
.IsRequired();
HasKey(on => on.XX);
Property(on => on.XY)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XY")
.IsRequired();
EDIT: XY is set in the model before .SaveChanges(); XX on the other hand is AI.
entity-framework sqlite
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
EF DB first approach. During an insert the exception: "SQLite NOT NULL constraint failed (XX)" occurs. However, no exception will be thrown if I use the SqlClient provider against a MSSQL DB.
Table:
- XY, PK, FK, int not null
- XX, PK, int not null
Model-Configuration
ToTable("Table");
Property(on => on.XX)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XX")
.IsRequired();
HasKey(on => on.XX);
Property(on => on.XY)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XY")
.IsRequired();
EDIT: XY is set in the model before .SaveChanges(); XX on the other hand is AI.
entity-framework sqlite
EF DB first approach. During an insert the exception: "SQLite NOT NULL constraint failed (XX)" occurs. However, no exception will be thrown if I use the SqlClient provider against a MSSQL DB.
Table:
- XY, PK, FK, int not null
- XX, PK, int not null
Model-Configuration
ToTable("Table");
Property(on => on.XX)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XX")
.IsRequired();
HasKey(on => on.XX);
Property(on => on.XY)
.HasDatabaseGeneratedOption(DatabaseGeneratedOption.None)
.HasColumnType(EntityFramework.IntDbType)
.HasColumnName("XY")
.IsRequired();
EDIT: XY is set in the model before .SaveChanges(); XX on the other hand is AI.
entity-framework sqlite
entity-framework sqlite
edited Nov 12 at 20:03
asked Nov 12 at 19:30
Thomas Christof
284416
284416
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53268869%2fsqlite-not-null-constraint-failed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown