Tag: entity-framework

Entity framework CREATEs against SQL Server DB nonnullable columns

I am using EFv4 for my ORM and I just tried to insert a record into a table that has multiple columns marked as not nullable and with a default value of empty string (for nvarchar type columns). The problem is that EF does not pick up default values for this column and when I […]

MySql or MS Sql Server with .Net Application

I’m developing a software using .Net platform. I want to know is it better to use MySql instead of MS Sql Server Express or not? My concern is the DBMS integration with ADO.NET and Entity Framework. Of course I don’t want to rewrite the codes which Microsoft has written for integrating MS SQL Server and […]

SQL Server 2008 View with LEFT OUTER JOIN fails on Entity Framework 4

SQL Server 2008R2 Entity Framework 4.x (early version) I recently changed a view within a SQL Server 2088 R2 instance so that it now contains some LEFT OUTER JOINS instead of INNER JOINS which causes some fields to contains NULL now. That leaves with a exception that this fields are not allowed to be null […]

Entity Framework and SQL Server Tuning Advisor

How do I use SQL Server Tuning Advisor to produce recommendations based on Entity Framework queries? Entity Framework uses sp_executesql ‘query’ instead of executing the query and Tuning Advisor does not recognize these queries. I could get the query text manually, but this will only work for very simple scenarious. How do I do it […]

Importing SQL Server's CONTAINS() as a model defined function

I am trying to import SQL Server’s CONTAINS() function in my Entity Framework model so that I can use it in my LINQ queries. I have added this to my EDM: <Function Name=”FullTextSearch” ReturnType=”Edm.Boolean”> <Parameter Name=”Filter” Type=”Edm.String” /> <DefiningExpression> CONTAINS(*, Filter) </DefiningExpression> </Function> Add created my method stub: [EdmFunction(“MyModelNamespace”, “FullTextSearch”)] public static bool FullTextSearch(string filter) […]

EntityFramework not updating column with default value

I am inserting an object into a SQL Server db via the EntityFramework 4 (EF). On the receiving table there is a column of (CreatedDate), which has its default value set to getdate(). So I do not provide it to the EF assuming its value will be defaulted by SQL Server to getdate(). However this […]

Get total row count in Entity Framework

I’m using Entity Framework to get the total row count for a table. I simply want the row count, no where clause or anything like that. The following query works, but is slow. It took about 7 seconds to return the count of 4475. My guess here is that it’s iterating through the entire table, […]

Entity Framework The ALTER TABLE statement conflicted with the FOREIGN KEY constraint

On updating database in Entity Framework , Code first Migration, I am getting this error: The ALTER TABLE statement conflicted with the FOREIGN KEY constraint “FK_dbo.Clients_dbo.MedicalGroups_MedicalGroupId”. The conflict occurred in database “hrbc”, table “dbo.MedicalGroups”, column ‘Id’. This is my class: public partial class Client { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public […]

Entity Framework 5 mixing Oracle & SQL Server

I have 2 data layer DLL projects. One is hitting Oracle tables and the other SQL Server. Each one works on their own when used in separate projects. When I make a project that includes both DLL’s I get the following error when an Oracle table is queried: Schema specified is not valid. Errors: Model.ssdl(2,48) […]

Dynamic query with OR conditions in Entity Framework

I am creating a creating an application that searches the database and allows the user to dynamically add any criteria (around 50 possible), much like the following SO question: Creating dynamic queries with entity framework. I currently have working a search that checks each criteria, and if it is not blank it adds it to […]

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