I have set DeletedFlag column as Not Null in database. I have also changed Conceptual Model and Storage Model accordingly. Both has column definition as
<Property Name="DeletedFlag" Type="Boolean" Nullable="false" DefaultValue="false"/>
still EF trying to insert null in this field hence throwing exception.
Cannot insert the value NULL into column 'DeletedFlag', table
'xxxxx.dbo.TblUsers'; column does not allow nulls. INSERT fails.
PS I can't update my model from database because it will mess up many things.
Related
I am trying to copy data from a cosmosdb container to an Azure SQL database table using Azure Data Factory.
Some of my columns in cosmosdb are not mandatory and might not be defined. The issue is that for every of these columns, I get the following error when running the copy activity :
Data type of column 'MyProperty' can't be inferred from 1st row of data, please specify its data type in mappings of copy activity or structure of DataSet.
However I checked in the mapping tab and the types of these properties are correctly infered to string, and they are well nullable in my SQL stored procedure table type.
I also have the same problem for optional decimal properties where the errors says that the value can't be parsed to Int64, though the infered type in the mapping tab is set to number and not integer...
Here is the mapping I currently have :
And the stored procedure with the table type
CREATE TYPE [dbo].[MyTableType] AS TABLE
(
[Id] varchar(256) NOT NULL PRIMARY KEY,
[SupplierId] varchar(256) NOT NULL,
[SupplierClientId] varchar(256) NULL,
[BuyerId] varchar(256) null
)
CREATE PROCEDURE [dbo].[UpsertItems]
#itemsTable MyTableType readonly
AS
BEGIN
MERGE MyTable AS target
USING #itemsTable AS source
ON (target.Id = source.Id)
WHEN MATCHED THEN
UPDATE SET
SupplierId = source.SupplierId,
SupplierClientId = source.[SupplierClientId],
BuyerId = source.[BuyerId]
WHEN NOT MATCHED THEN
INSERT (Id, SupplierId, SupplierClientId, BuyerId)
VALUES (
source.Id,
source.SupplierId,
source.[SupplierClientId],
source.[BuyerId]);
END
I can't find a way to force the datatype of this property either in the dataset directly of in the mapping tab of the copy activity. How can I fix the issue ?
You can specify the data types if you are creating a new table while copy. But if you are adding or copying to an already existing table, the data type is inferred automatically.
While, auto creating table in copying
If this does not help, please share sample source data and some snips
I created word constraint on element repository
<constraint name="repository">
<word>
<element ns="http://lmpublishlearning.com" name="repository"/>
</word>
</constraint>
we have some document in which element repository value is blank like
<lmp:repository/>
Now in our search application how I can pass above type to get blank value document with word constraint. I try below different case but not able to get result.
rs:q=repository:''&rs:pageLength=10&rs:start=1&rs:sort=relevance"
rs:q=repository:""&rs:pageLength=10&rs:start=1&rs:sort=relevance"
It might meet your requirements to write a custom constraint:
http://docs.marklogic.com/guide/search-dev/search-api#id_97085
that returns
a cts:element-word-query on a tagged value that's not empty
a cts:element-value-query on a tagged value that is empty
Hoping that helps,
I 'm working on an ASP.NET Dynamic Data Entities Web Application.
When trying to insert a new entry in one of the tables, with some value in the column_name field, I get the following message :
Cannot insert the value NULL into column 'column_name', table 'DATABASE.dbo.table_name'; column does not allow nulls. INSERT fails.
The column properties are :
Entity Key : True
Nullable : False
Type : String
I believe Dynamic Data is trying to send null value to entity framework for some reason, but I don't know which.
Do you know why Dynamic Data is behaving that way ?
Or have you any idea how to debug the insert process ?
Thanks
I found where the problem come from. A table from the database the model is based contains a trigger. For some reason the model makes an association between the two tables involved in the trigger.
I have stored procedure which returns "Tabular data" and have only "Get method".
I unchecked "Fill a DataTable" checkbox. And Method name is empty field.
So, i only have a Get method to get rows from database table.
SQL code works fine when i tried it in SQL management studio.
But when i create a stored procedure, i get an alert:
I use BLL/BO/DAL architecture
I call my stored procedure like:
MyDataTable dt = myAdapter.MyStoredProcedure();
And the i get an error:
"System.Data.ConstraintException: Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints"
What i am doing wrong?
Check this same issues
Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints
http://forums.asp.net/t/1258783.aspx/2/10
I'm running NHibernate and SQL Server CE I am trying to use GUIDs as my ID column. This is the code I already have:
Mapping:
<class name="DatabaseType" table="DBMON_DATABASE_TYPE">
<id name="Id" column="DATABASE_TYPE_ID">
<generator class="guid" />
</id>
<property name="DispName" />
</class>
And this is the create statement it creates:
create table DBMON_DATABASE_TYPE (
DATABASE_TYPE_ID BIGINT not null,
DispName NVARCHAR(255) null,
primary key (DATABASE_TYPE_ID)
)
And this is the kind of insert statement I want to be able to run on it:
Insert into DBMON_DATABASE_TYPE (DATABASE_TYPE_ID,DISPNAME) values ('f5c7181e-e117-4a98-bc06-733638a3a264','DOC')
And this is the error I get when I try that:
Major Error 0x80040E14, Minor Error 26306
> Insert into DBMON_DATABASE_TYPE (DATABASE_TYPE_ID,DISPNAME) values ('f5c7181e-e117-4a98-bc06-733638a3a264','DOC')
Data conversion failed. [ OLE DB status value (if known) = 2 ]
Once again my goal is to be able to use GUIDs as the ID column of my table, they don't even need to be auto generated, I can generate them manually in the Save/SaveOrUpdate methods of NHibernate. If there is any other information you need to know please let me know!
In your mapping you need to identify that you want NHibernate to create a GUID in the database schema (it looks like you are generating your schema from the nhibernate mapping). Off the top of my head the following should work:
<id name="Id" column="DATABASE_TYPE_ID" type="Guid">
<generator class="guid" />
</id>
instead of
DATABASE_TYPE_ID BIGINT not null,
it needs to be
DATABASE_TYPE_ID UNIQUEIDENTIFIER not null,
I would strongly advice you to use NEWSEQUENTIALID() as a default instead since you are using it as a clustered index because it won't cause page splits and thus fragmentation, see here how to use it http://msdn.microsoft.com/en-us/library/ms189786.aspx
Dare I recommend using GuidComb's instead?