RSS

Category Archives: SQL

Unable to update the EntitySet because no <InsertFunction> element existing

Today I received a strange error when saving a newly created entity into the database.

Unable to update the EntitySet ‘EntityName’ because it has a DefiningQuery and no <InsertFunction> element exists in the element to support the current operation.

Well this is strange. The EntityName is a table in SQL and there should be no problems in inserting a new entry by using conn.Set<EntityName>().Create().

Looking at the SQL script to create the table, I realized that the problem was, that no Primary Key has been defined for the table. Therefore Entity Framework decided that EntityName should be traced as a View. Adding a primary key solved the above shown issue.

Advertisements
 
Leave a comment

Posted by on May 28, 2015 in C-Sharp, EF, SQL

 

Tags: , ,

sql71502 when using INSERTED keyword

Recently I had a strange exception when using the INSERTED keyword. It always mentioned that the Id property does not exists on table X.

SQL71502-Exception

The solution is rather simple. Just put the scheme name to your table then the exception is gone.

SQL71502-Solution

 
Leave a comment

Posted by on January 20, 2014 in SQL

 

Error 04018: The “SqlBuildTask” task failed unexpectedly

I intend to use a SQL Server Database Project in my Visual Studio Solution to manage the database. This is a very nice feature and you should try it. Nevertheless, after upgrading the SQL Server Management Studio 2012 to SP1 I was not able to build the SQL Server Database Project anymore. I always got the following error message:

Error 2 04018: The “SqlBuildTask” task failed unexpectedly. System.MissingMethodException: Method not found: ‘Void Microsoft.Data.Tools.Schema.SchemaModel.DataSchemaModel.Serialize(System.IO.TextWriter, System.Collections.Generic.IEnumerable`1)’. at Microsoft.Data.Tools.Schema.Sql.Build.SqlTaskHost.SerializeModel(String outputFile) at Microsoft.Data.Tools.Schema. Tasks.Sql.SqlBuildTask.ExecuteSerializeModelStep() at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.ExecuteStep(Func`1 step) at Microsoft.Data.Tools.Schema.Tasks.Sql.SqlBuildTask.Execute() at Microsoft.Build.BackEnd. TaskExecutionHost.Microsoft. Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd. TaskBuilder.d__20.MoveNext() C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\SSDT\ Microsoft.Data.Tools.Schema.SqlTasks.targets

After a few attempts, I found the solution. I just downloaded and installed the new version of (SQL Server Data Tools)[http://msdn.microsoft.com/en-US/data/hh297027] and the exception has disappeared.

 
5 Comments

Posted by on January 16, 2013 in SQL, Visual Studio

 

Tags: ,

Reporting Server rsAccessDenied Windows 7,8

If you install SQL Reporting Server on Windows 7, 8 and you want to start to configure it, even as administrator, you will get following exception:

The permissions granted to user ‘domain\username’ are insufficient for performing this operation.

The solution that is provided in the MSDN library, saying that you should start the Internet Explorer as local administrator or adding the host trusted site would not work. After hours of search, I found an interesting post saying that the only thing you should do is to create following registry-key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System] DWORD
“LocalAccountTokenFilterPolicy” = 00000001

The change is immediately applied, therefore no restart is needed.

 
2 Comments

Posted by on January 11, 2013 in SQL, Windows 7, Windows 8

 

Tags: , , ,

SQL Database State stuck in Restoring

If you have the issue that your database state stuck in the restoring state forever, then you have to execute a single command. Without executing you will not be able to access a database in the restoring state. Execute following command:

RESTORE DATABASE DatabaseName WITH RECOVERY

Then your state will change again back to Normal and you can access the database again.

 
3 Comments

Posted by on July 27, 2012 in SQL

 

Tags: , , ,

SQL Concatenation

As you have seen in the article SQL Concatenating: NULL problem you may have problems concatenating a set values if one of them contains a NULL value. Another problem might be if you concat values of different type.

SELECT CAST(1 as nvarchar)+'st TE'+null+'ST' --Results in NULL
SELECT 1+'st TE'+null+'ST' --results in InvalidCastException from varchar to int.

Beginning with the new SQL Server 2012 there is a new function called CONCAT that concatenates a bunch of objects. The cool feature is that there can be concatenated object of different type like NVARCHAR, INT, FLOAT, etc. You can also concatenate NULL without getting NULL as result. Additional you must not to convert the values to nvarchar prior passing as parameter to the CONCAT function.

SELECT CONCAT(1,'st TE',null,'ST') --Results in 1st TEST
 
Leave a comment

Posted by on July 24, 2012 in SQL

 

Tags: ,

SQL Server Data Tools Installation hangs

If you try to install the SQL Server Data Tools you might have the situation that the installation process hangs on a particular package. You can wait and wait, but the installation process will not continue.
I do not know why this happens, but I got a solution. Cancel the install process via the Task Manager by killing the process. Open the SQL Server 2012 Feature Pack site and download and install/repair the component that suspends the installation process. Then you can retry installing the whole suite.

 
Leave a comment

Posted by on June 4, 2012 in SQL, Visual Studio

 

Tags: