Tag: entity-framework

Entity Framework : Schema specified is not valid

I am developing a web application that is using Entity Freamwork 5 Visual Studio 2012 and it need to support both SQL Server and Oracle database providers. I created entity model for Oracle Database. I thought it would work after some changes in connectionstrings, bu no it is not that easy .. I found this […]

Issue while implementing Entity Framework 6.0 in VS 2012

While implementing Entity Framework 6.0 in VS 2012 (i.e. creating edmx file & tried to generate my Model class out of it), I got below error message (even though Test Connection to DB is succeeding). The ‘SqlStudio Profile Package’ package did not load correctly As a resolution step I tried to re install “Microsoft SQL […]

EF5: LINQ to Entities does not recognize the method System.Nullable System.Decimal Median

I’m using EF5 Code first. When I execute my query: var priceIndexQuery = from r in unitOfWork.Repository<StockIndexPriceResult>() where request.CalculateModel.StockCompanies.Contains(r.StockCompanyId) && r.StockIndexId == request.CalculateModel.StockIndexId && r.ResultDate >= dateFiveYearsAgo orderby r.ResultDate descending group r by r.ResultDate into g select g; and then: var query = priceIndexQuery.Select(g => new CalculateAggregateModel { ResultDate = g.Key, Value = g.Median(p => […]

Updating a relationship in Entity Framework generates SQL error

I’m getting headaches here. I’ve got a one to zero-or-one relationship between a Session and a User object, designed in Entity Framework 4 using the model first approach. A User should have a session (one) A Session can have a User (zero-to-one). So, in runtime I pull a session from the database using Session session […]

Entity framework 5.0 context reload

When I edit data directly in the database, the modified fields are not updated in ENTITY FRAMEWORK CONTEXT, only new and deleted rows are updated. (using one ObjectContext for the whole workflow)

How can I check existence of a stored procedure and view and function in seed method of Entity Framework?

I have an ASP.NET MVC web application and Entity Framework code first. I use a stored procedure and views and functions for my report section in my project. Then I want to after updating my database these stored procedure and views and functions dos not clean and drop after updating. I use this way and […]

Entity Framework 6 + SQLSpatialFunctions

I’m in the process of migrating a code base from the Entity Framework 5 to 6. I’ve found documentation to assist in this but I’m finding some challenges with the changes made to DBGeography and specifically SQLSpatialFunctions. EF6 contains breaking changes that include removing classes out of System.Spatial over to System.Data.Entity.Spatial (and into the core […]

Entity Framework table updates not working due to trigger calling CLR

I have a table with a trigger that points to an assembly: CREATE TRIGGER [dbo].[triggername] ON [dbo].[tablename] WITH EXECUTE AS CALLER AFTER DELETE, UPDATE NOT FOR REPLICATION AS EXTERNAL NAME [Namofassembly].[blahblah].[blahblah] We also using code first EF in .net 4. When I use delete everything works fine but the trigger does not get called. dataRepo.UsersPermanentAuditAssignments.Remove(isInsertFound) […]

What's the advantage of using LINQ when I query a database with EF6?

I have been using EF6 for my application and will soon move to 6.1. Normally all my EF is handled with LINQ like this: var exams = _examsRepository .GetAll() .Where(q => q.SubjectId == subjectId) .Include(q => q.Tests) .ToList(); However I just had a suggestion to use this for a particular query: var exams1 = (from […]

entity framework simple subquery generates ugly sql

I’m trying to optimize the following simple Entity Framework query to retreieve all the products from the same group var query = from p in ctx.Products where p.GroupId == ( from q in ctx.Products where q.Id == new Guid(“…..”) select q.GroupId).FirstOrDefault() select p; After checking the generated sql using SQL Server Profiler I see this […]

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