Tag: entity-framework

Procedure expects parameter '@statement' of type 'ntext/nchar/nvarchar while executing a stored procedure with Entity Framework

I am getting error that procedure expects parameter ‘@statement’ of type ‘ntext/nchar/nvarchar while executing a stored procedure with Entity Framework. This is my stored prodecure: Create Procedure [dbo].[usp_RolesList] (@WhereCond varchar(50)) AS Begin Set NoCount ON Declare @SQLQuery AS Varchar(max) Set @SQLQuery = ‘Select * From dbo.AspNetRoles ‘ + @WhereCond Execute sp_Executesql @SQLQuery End and this […]

App Parent Folder Permissions in Entity Framework

I have a WPF app that uses Entity Framework to connect to a SQL database. Upon compilation of the app I copy the files over to the published location where I have a number of apps, for example: I:\Apps\App1\[App Files] I:\Apps\App2\[App Files] etc, etc…. Where I is a mapped network drive mapped via GPO. If […]

EF 6 use Convert (Cast) on sql side for natural sort

I have the following issue, a column in my database of type varchar it consists of letters and numbers the issue is I want the results sorted naturaly. So 1,2 .. 10, 11 Currently I am getting 1,10,11,..,2 On SQL side this can be done with the following query SELECT [ID] ,[ChangedAt] ,[ChangedBy] ,[CreatedAt] ,[CreatedBy] […]

Crystal reporting using VS 2015 and MVC5

I’m new in MVC5, i got this error when using Crystal reporting tool, An exception of type ‘System.NotSupportedException’ occurred in System.Data.dll but not handled in user code Additional information: ‘DataSet’ does not support System.Nullable <>. using CrystalDecisions.CrystalReports.Engine; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.Mvc; namespace CrystalReportMVC.Controllers { public class CustomerController […]

Linq Entity – Expression Function In Where Clause

I´m making a databinding a ASPxGridview with mode EntityServerModeDataSource (the demo ) I’m using a Entity Framework (ef6) like source of data and i´m loading the grid with a Linq expression: protected void EntityServerModeDataSource1_Selecting(object sender, DevExpress.Data.Linq.LinqServerModeDataSourceSelectEventArgs e) e.QueryableSource = from emps in MyEntity.TableEntities join y in MyEntity.SubTableEntities on emps.IDTableEntities equals y.IDTableEntities join z in MyEntity.TblAcessProfiles […]

Code First calling a stored procedure passing in 3 params validation errors

I have been successful with calling a stored procedure when passing in just 1 parameter, but now with my code first dbcontext, I am wanting to keep it simple, but I altered the code based on some answer I seen :/ not working OK, first off here is code that does work: var param = […]

Entity Framework Cannot Open Database Requested By the Login – The Login Failed For User

I’ve just uploaded my website to a server and getting an error called “cannot open database requested by the login the login failed login failed for user”. In my global.asax file on Application_Start method, I have this : Database.SetInitializer<MyContext>(null); So I created my database manually and after used script to create tables. But when I […]

SQL Server – Concatenated string sequence as primary key – Insertion fail via EF code

I am using SQL-Server 2016 and Entity Framework Core. Let’s say we want to use a concatenated string to a sequence as a primary key of a table. I have created the table using Code-First migration successfully, and have set the default value of the column to be the desired concat (Screenshot from SSMS): When […]

Add-Migration and Update-Database commands not found Visual Studio 2015

I’ve seen similar questions to this and I’ve tried every posted solution to all of them. I’ve been trying to fix this seemingly simple problem for the past two days and have gotten nowhere. When I try to run Add-Migration or Update-Database from the Package Manager Console, I get the following error: Update-Database : The […]

Auto assign column value when row is created

I am using EF6 and SQL Server 2014. I have something like the following simplified model: public class Order { public int Id { get; set; } public DateTime Created { get; set; } public IEnumerable<OrderItem> OrderItems { get; set; } } public class OrderItem { public int Id { get; set; } public int […]

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