Tag: entity-framework

Generating models/poco classes to be used by entity framework from sql server

I can generate poco classes using Entity Framework Power Tools which works perfectly fine, but now I have bit different requirements. I want to generate two types of model projects from database. Internal model External model Internal model will most likely carbon copy of sql with slight modifications so this isn’t a problem, we can […]

How to fix Entity Framework Core temporary table generating fields which are too small

I have a EF Core solution which must import various data. Basically I generate a bunch of entities in my web service, and then tell the DB to save, but something strange happens in some cases. Note that the following field “Value” has an nvarchar(max) in the final table, but EF Core generates a temporary […]

T-sql to asp.net Entity framework

Select TOP 5 * From Kaloriler Where KaloriAdi Like ‘%cikolata%’ COLLATE Latin1_general_CI_AI What is the equivalent in Entity Framework? .Where(x => x.KaloriAdi.Contains(“cikolata”)); But how can I use it COLLATE Latin1_general_CI_AI?

EF select is not getting record

I have a large project with lots of data access going on. I just added a new table (from db) and the standard EF query is not working, but a sql query works. Here’s the data access: public Topic GetTopicByName(string name) … name value is KboInterestingTopic { var topics = from t in _db.Topics where […]

Entity Framework : Unable to change DataSource for Code First Migrations

I am working on a project where I am using Entity Framework along with code first migrations to update my database. I started this project on another machine and it worked out very well. Now I checked out the code on another machine. Since this machine does not have the database, I ran update-database command […]

Entity Framework One-to-one or zero – Database first

I’m trying to create a setup where I have different entities (e.g. User and Customer). Each of these entities have some Login-information which I store in a Login-table to avoid having to do duplicate work on the different entities requiring Login-data. However – I can’t get the setup to work using Entity Framework. I hope […]

How to drop and recreate indexes without growing the transaction log

I wanted to change a field in a database table to be a calculated field rather than being populated using a trigger. I am using Entity Framework database first so I added this sql to a migration to carry out the task: EXECUTE(‘ALTER TABLE [dbo].[BaseAnsweredQuestions] DROP COLUMN [CalculatedDueDate] ‘) EXECUTE(‘ALTER TABLE dbo.BaseAnsweredQuestions ADD CalculatedDueDate AS […]

Changing ntext to nvarchar using C# and Entity Framework

I have to add sorting to existing database created in SQL Server. The problem is that this database contains ntext columns that are not supported by LinQ’s OrderBy method. The database was written in a code-first approach, so I have access to template of database, but I can’t look at ready database working on the […]

Linq to SQL 2016 Stored Procedure OFFSET FETCH NEXT incorrect return type

I have an interesting issue that has kept me googling for a couple of days. I am executing a stored store procedure that implements Offset Fetch Next for custom .net paging. The entity framework can’t seem to figure out the correct return type. It thinks I am trying to return an int instead of a […]

Accessing virtual child object executes sql without WHERE clause

I have tried to research why, what I believe should be a relatively straightforward concept, is not working as expected. From what I have read the following should work in the way I expect, but it isn’t. I am retrieving data from an SQL database using entity framework, however I cannot get Lazy / Deferred […]

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