Tag: entity-framework

The version of SQL Server in use does not support datatype datetime2?

An error occurred while executing the command definition. See the inner exception for details. bbbbInnerException:aaaa System.ArgumentException: The version of SQL Server in use does not support datatype ‘datetime2’. at System.Data.SqlClient.TdsParser.TdsExecuteRPC(_SqlRPC[] rpcArray, Int32 timeout, Boolean inSchema, SqlNotificationRequest notificationRequest, TdsParserStateObject stateObj, Boolean isCommandProc) at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, […]

EF 6.1 Unique Nullable Index

In EF 6.1 using Code First you can create Indexes using Attributes in your Entities or using the fluent API along the lines of: Property(x => x.PropertyName) .IsOptional() .HasMaxLength(450) .HasColumnAnnotation(“Index”, new IndexAnnotation(new IndexAttribute(“IX_IndexName”) {IsUnique = true, })); Is there any way to say scaffold WHERE PropertyName IS NOT NULL in the same way you would […]

How to get next value of SQL Server sequence in Entity Framework?

I want to make use SQL Server sequence objects in Entity Framework to show number sequence before save it into database. In current scenario I’m doing something related by increment by one in stored procedure (previous value stored in one table) and passing that value to C# code. To achieve this I needed one table […]

DateCreated or Modified Column – Entity Framework or using triggers on SQL Server

After I read one question in attached link, I got a sense of how to set DateCreated and DateModified columns in Entity Framework and use it in my application. In the old SQL way though, the trigger way is more popular because is more secure from DBA point of view. So any advice on which […]

Can we run sql script using code first migrations?

Can we run sql script using code first migrations? I am new to code first and if i want to save my changes to a sql script file before update-database command of migration, is it possible? If possible then please provide steps to get it done. Also if script is generated then is it posible […]

How to Identify the primary key duplication from a SQL Server 2008 error code?

I want to know how we identify the primary key duplication error from SQL Server error code in C#. As a example, I have a C# form to enter data into a SQL Server database, when an error occurs while data entry, how can I identify the reason for the error from the exception?

Entity framework very slow to load for first time after every compilation

As the title suggest i’m having a problem with the first query against a SQL Server database using the Entity Framework. I have tried looking for an answer but no one seems to actually have a solution to this. The tests was done in Visual Studio 2012 using Entity Framework 6, I also used the […]

Create ASP.NET Identity tables using SQL script

I am attempting to incorporate ASP.NET Identity into a new application that currently uses a SQL script to create the database schema. As we will need to create Foreign Key constraints from other tables to the user tables, it is highly desirable that the ASP.NET Identity tables are also created in the same scripts. I […]

Windows Azure SQL Database – Identity Auto increment column skips values

Currently working on an ASP.Net MVC 4 application using Entity Framework 5. Used CodeFirst for initial development phase. But have now disabled the Automatic Migrations and designing new tables directly using SSMS and writing POCO. Everything is working good. Recently, identified a weird issue in Production. The records in one of the initially designed tables […]

The object 'DF__*' is dependent on column '*' – Changing int to double

Basically I got a table in my EF database with the following properties: public int Id { get; set; } public string Title { get; set; } public string Description { get; set; } public string Image { get; set; } public string WatchUrl { get; set; } public int Year { get; set; } […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.