Click here to Skip to main content
15,887,822 members
Everything / Entity Framework

Entity Framework

entity-framework

Great Reads

by Jovan Popovic(MSFT)
Mapping properties in EF model to database columns that contain JSON
by Kenji Elzerman
Fundamentals of Entity Framework
by Akhil Mittal
Entity framework core, code first migrations and data annotations in EF Core
by Jean Carlo S. Passos
CRUD over Association Entity that maps to association tables

Latest Articles

by GabrieleTronchin
In this project, I've implemented the Transactional Outbox Pattern using EF Core.
by David_Cui
To introduce a free library to save some tedious work for writing mapping code between entities and DTOs
by Mark Pelf
Fix for adding new DB tables does not work in VS 2022, ver. 17.6.2, EF6 (Classic)
by Mark Pelf
Tutorial on EF7 – Code First approach using Command Line (CLI)

All Articles

Sort by Title

Entity Framework 

31 Aug 2010 by helianthus87
Here's the scenario.After page loaded user is getting List of his for example Phones. He can modify, delete, add some records without databse interaction during this process. After this he can click "Save" button to populate all changes to database.My problem is:At the end of user's...
1 Sep 2010 by Gordon Kushner
My technique is to pass in all the ids to the stored procedure. You can do this with XML.Using the XML data type, you can DELETE the ids in dbPhones that are NOT IN the ids for userPhones, UPDATE the matching records and INSERT the new ones in one procedure call.Here is a SQL Server 2005...
12 Sep 2011 by foxrox_1
Hello.I have a question about firing an event or call a method in a certain condition (eg if(datetime1 > datetime2) )Basically I need to send birthday emails to someone registered on my website at his/her birthday at Midnight.Then, each hour, I need to send a PM to me containing an...
12 Sep 2011 by Herman<T>.Instance
if (DateTime.Now > Midnight) counts for a complete day!Better create a service that runs on midnight once for the birthday emails and hourly for the PM
13 Sep 2011 by BobJanova
There's basically two options here.Best is if you either own the server or are permitted to run a service or cron job (sorry, scheduled process ;) ) on it. Set the service up to check once an hour for anyone whose birthday tripped in the last hour, and send you a PM (i.e. write to a database...
13 Sep 2011 by AditSheth
Create a job that will execute at MidNight. Step To Create JobNow in Job Find users which has birthday today and send email. To send email use Database Email Here you find step to send email
14 Aug 2018 by Niranjan Vinay
If the pass the registered email id and password to login it's showing the error. There is Exception thrown in entityframework.dll and Repository.dll What I have tried: I have tried deleting .vs folder. Tried cleaning the source and rebuild it.
U 16 Apr 2024 by GabrieleTronchin
In this project, I've implemented the Transactional Outbox Pattern using EF Core.
30 Apr 2018 by M.Kamran Asim
Dear Friends, I have started my new project in .Net core 2.0. Recently I did some research for best suited ORM, which is fast and easy to use. I found Dapper as a king of ORM, but it has many limitation. To overcome these limitation I found solution to use hybrid approach by combining Entity...
18 Oct 2020 by JawadHasan
Use NoSQL database functionality from within a Relational database system
27 Dec 2014 by Thebusker
Hello to all,my Hosting Provider don't allow to use the default user called "dbo" (on mssql 2008 server).I'm using the standard Membership in Visual Studio Express 2012 (or VS2010) for Registration and Login pages, but the Entity Framework/Membership .dll creates tables and vistas by "dbo"...
28 Sep 2011 by Member 4550493
Hi,I am working on Entity Framework 4.1. I have created sample application in which i have three Entitees 1] Order EntityOrderNumberOrderDateStatusCustomerId2] OrderItem EntityOrderItemNoQuantityPriceOrderNumber3] Shipping...
28 Sep 2011 by Simon Bang Terkildsen
First of all, don't just tell us you recieve an exception, if you do not post the exact exception then you might aswell just don't mention it at all.That said in a 1 to 1 relation the EF expects that the two tables use the same primary key, which they also should.So making OrderNumber the...
5 Sep 2018 by Saineshwar Bageri
How to secure ASP.NET Core MVC Applications against top 10 attacks
29 Nov 2015 by Michael Bogaerts
What brings the 15.2 release for XAF (win) developers
24 Oct 2015 by Sergey Alexandrovich Kryukov
You are mixing up layered architectures with multi-tier architecture. The are different things. You need to learn about each of them separately.—SA
7 Sep 2019 by Lee P Richardson
This blog post lists 3 days to refactor EF Linq queries without killing Perf
30 Nov 2019 by Taher El Marengoze
I am trying to develop a WinForms application, the application is a procurement system where employees at different locations (SITE) send purchase requests containing transactions that must be carried out by the procurement employee(HO). I am using c# and Entity Framework 6 (Database-First...
27 Nov 2019 by johannesnestler
Why do you think SQLDependency won't work with EF? (I didn't check for EF 6 but this worked for me back then: SqlDependency with Entity Framework 5.0[^]
30 Nov 2019 by Taher El Marengoze
Well I tried SQL Dependency using Entity Framework in WPF[^] and it worked like charms. But I don't know if it has any limitation or not, I guess time will tell. Anyways, thanks everyone for your answers.
24 Mar 2014 by Alem.B
Hi!I have some difficult time to pass data to Partial view httpPost ActionResult method in Controller.Let me explain:1.Have entity which i have been generated with Entity Framework ORM and this looks like this.
31 Mar 2014 by Guruprasad.K.Basavaraju
In your view change the IEnumerable to List, that solved a similar issue I had.@model ListIEnumerables are readonly.
4 Feb 2014 by Bahram Ettehadieh
I need a good and professional sample solution developed based on MVC and Entity Framework(Database First) any suggestions?
4 Feb 2014 by Tadit Dash (ତଡିତ୍ କୁମାର ଦାଶ)
Refer Sergey's comment. This usually don't work this way in Code Project.You have to come with a specific issue.Still I would give you some article links, which might be useful for you to get started. Just go through them.1. EF Database First with ASP.NET MVC: Setting up the Database[^]....
4 Feb 2014 by JoCodes
Additional Referenceshttp://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/database-first-approach-in-entity-framework/[^]http://nerddinner.codeplex.com/[^]http://csharppulse.blogspot.in/2013/08/learning-mvc-part-3-creating-mvc.html[^] Learning MVC - Part 5 Repository Pattern in...
16 Apr 2011 by DannyStaten
I am using Entity framework for my project with sqlite as the database. I need to let the user choose their file at run time, and I would think that I have it all squared away. However when I construct my EF entities object it throws an exception and I can't figure out what I am...
16 Apr 2011 by DannyStaten
Ok I found my problem. I coppied my connection string straight from an app.config. The culprit was the " in the two places it was showing up. Changing it to 'data source={0}' solved the issue.
19 Sep 2015 by Member 11594357
can you please write the final connection string needed?im in the same problem..
4 Oct 2011 by Sunasara Imdadhusen
HiAll,I would like to use something like AutoMapper for the following code instead of manual mapping.I have two tables User and Role and both mapped with RoleID. now problem is if i am getting records from Users then it will gives me only RoleID instead of RoleName. So i tried to get...
4 Oct 2011 by Sunasara Imdadhusen
I have SOLVED this question using following solution:public IList GetUsersWithRole() { IList users = _UserRepository.GetAll(); IList userswithrol = new List(); AutoMapper.Mapper.CreateMap
23 May 2014 by Neha Mukesh
protected void SaveAttachments(Int32 actRuleID) { if (gvAttachments.Rows.Count > 0) { if ((Session["FileDetail"].ToString() != "")) { string[] Records = Session["FileDetail"].ToString().Split('#'); byte[]...
21 May 2014 by Raul Iloc
1.This error occurs because you are trying to access the property/method of a null object. 2.You should Debug your code and inspect in your code that generate the exception the values of the used variables, and one of it should be null.PS: Normally when you read something from Session...
21 May 2014 by Karen Mitchelle
Additional to the Solution 1, kindly check for the variables. Maybe they don't generate a value that's why you're getting an exception.If you are using Visual Studio, use breakpoint so that you can see in what specific line you are having problems with.
29 Jan 2011 by [DK]KiloDunse
Hi.When I use this select in a entitydatasource.CommandText:CommandText="SELECT it.[LiteratureID], it.[ReleaseDate], it.[Title], it.[Text], it.[ThreadID], it.[Added], (SELECT COUNT(fp.PostID) FROM ForumPosts AS fp WHERE fp.ThreadID = it.[ThreadID] AND fp.Status = 1) AS Posts FROM...
29 Jan 2011 by [DK]KiloDunse
Found a solution.Adding VALUE to the nested SELECT returned a list of Int32 insted.Binding like this, returned the value:Comments=''
2 May 2011 by Sachin Kumar, IGate
Thanks very much. It is really a very appeciatable help. I used in query like in aspx page : DefaultContainerName="DBEntities" EnableFlattening="False" EntitySetName="Logs" ...
27 Dec 2018 by tranthanhtu.vn
[TinyERP: SPA for Enterprise Application]Manage Staffs - Part 2
3 Feb 2013 by Rahul Rajat Singh
In this article we will try to see how we can model tables having one to many and many to many relationships using Entity Framework.
6 Oct 2012 by Rahul Rajat Singh
This article talks about performing validations while using Entity framework. We will see how the Entities facilitate validations using partial methods.
17 Dec 2022 by Kenji Elzerman
Let's take a look at the very fundamentals of LINQ and how to use it.
15 Nov 2016 by scott_liu
Sometimes, a bug fix cannot meet the challenges by a regression test. So thinking twice for a better solution is worthwhile for troubleshooting and bug fixes.
9 Sep 2013 by Anele Ngqandu
Hi guysI get this error and not sure what to do, please help.Error:"A circular reference was detected while serializing an object of type "var context = HttpContext.Current; int rowCount = -1; var property = db_Property.getEveryProperty(0, 10, "", ref...
21 Apr 2014 by Jeff Moeller
Could this design solution be solved by Entity Framework?An app named "car parts" v1.0 has one user and incorporates a relational database with strongly typed columns for each of the 10 car parts that applies to the user's vehicle data.The data is very searchable since it is in an...
21 Apr 2014 by Jeff Moeller
Thanks you Sergey, it turns out that my question is about hybrid EAV patterns with SQL Server on which I'd appreciate any further input.
2 Apr 2023 by Marc Clifton
Using EntityFramework Core and SQL Server to create a dynamic IQueryable filtering that is not susceptible to SQL injection attacks
15 Feb 2012 by msk kumar
Hi all,i am using entity framework to access the Db in my projecthere i want to update two entity(table) by clicking a update buttonDim xx As entityname = objContext.entityname.Where(Function(c) c.Rowid = intRowId And c.Type = intType).SingleOrDefaultIf (true) ThenIf Not...
16 Feb 2012 by Not Active
If you want to update the entire object graph then ApplyCurrentValues is not necessary. http://msdn.microsoft.com/en-us/library/dd487246.aspx[^] "The ApplyCurrentValues(Of TEntity) method is used to apply changes that were made to objects outside the ObjectContext, such as detached objects...
8 Oct 2017 by David2509
hello i have to developpe a fuel products prices management system there are several prices with its formula that i have implemented and i have to calculate all this prices and store theme in database -price for domestic customers -prices for foreign customers -price for foreign regular...
8 Oct 2017 by F-ES Sitecore
1 There is rarely a "best" technology, but asp.net and mvc are certainly more than capable and a good option 2 It's up to you. These days people tend to use Entity Framework\LINQ as it's easier to do. Especially for simple operations like CRUD and basic queries so EF is probably a good option...
2 Mar 2018 by alirıza adıyahşi
Creating a multi-tenant (SaaS) web application based on ASP.NET Boilerplate and using ASP.NET Core, Angular and EntityFrameworkCore.
18 Feb 2018 by Halil ibrahim Kalkan
Creating a multi-tenant (SaaS) web application based on ASP.NET Boilerplate and using ASP.NET MVC, Angularjs and EntityFramework
22 Mar 2018 by Member 13586256
Hello I am using WPF using MVVM model with entity framework but i am getting this error while changing the value or foreign key column.I am using SaveOptions.AcceptAllChangesAfterSave option to save the change because or speed issue.Please help me. A referential integrity constraint violation...
22 Mar 2018 by OriginalGriff
We can't solve this for you: it's got too much to do with your data, and how you are manipulating it. What's happened is that a value is left in a table, or inserted into a table which depends on other table information, or which other tables depend on. For example, if you have an Invoices...
8 Mar 2011 by Weidong Shen
Part 2 of a series describing the creation of a Silverlight business application using Self-tracking Entities, WCF Services, WIF, MVVM Light Toolkit, MEF, and T4 Templates.
12 Apr 2011 by Weidong Shen
Part 4 of a series describing creation of a Silverlight business application using Self-tracking Entities, WCF Services, WIF, MVVM Light toolkit, MEF, and T4 Templates.
2 Jun 2015 by Gediminas Geigalas
I've been successfully using NHibernate as my first ORM for a few years. For the last year, I have decided to use Entity Framework instead. Here's what I liked and disliked.
26 Dec 2009 by Vinayaka Krishna Shenoy
From past few days i was doing some R & D on the upcoming Entity framework from Microsoft, and i found it was interesting in many ways,The first part which i liked the most is -Querying to the Entity Data Model(EDM) rather than the real data store.At a high level , we have plenty of...
3 Aug 2018 by Rahul Rajat Singh
This article introduces Dapper to absolute beginners.
14 May 2014 by Member 10226004
Hi, I created cache to the query results(i.e to dataset) in c# console application but i want to access the that created cache in my web application.If it is possible how can i access the cache in my web application fron console application.I dont have much knowledge in cache please give...
14 May 2014 by DamithSL
ASP.NET cache is Process/App domain specific, it can't be shared. Try below Advance Caching with Shared Cache[^]SharedCache - high-performance, distributed caching[^]Installing, Configuring and Using Windows Server AppFabric and the "Velocity" Memory Cache in 10 minutes[^]Distributed...
9 Jan 2013 by I.explore.code
Hi guys,I have just started out with ASP.NET MVC3/4 and I have hit my first wall. I have a model class and a view that is strongly typed to it and obviously a controller. This view has a WebGrid that defines several columns that are bound to the model and 2 date columns (text boxes...
17 Mar 2018 by Dodido_72
Hi! I am trying to add a product with many prices to a shopping cart(a one-to-many relationship entity framework). The customer has chosen a special size with its price in the product presentation (a short list with buttons on the right). Now I want to add this selected product, size and price...
30 Dec 2011 by mohammadghaderian.bp
HiI am working with visual studio 2010 and my application is on .net 4.I want to use ADO.NET Entity Framework but when i open add new item dialog , this item is not in my list .how can i solve this problem ?if should i install its component where can i download it ?thanks a lot for...
30 Dec 2011 by member60
Refer the following this might help you:[^]http://msdn.microsoft.com/en-us/library/bb399182.aspx[^]
31 Dec 2011 by RaviRanjanKr
Try ADO.NET Entity Framework and .NET 4 - How to use Visual Studio 2010 Modeling Tools to Build a Database[^]
10 Aug 2016 by F-ES Sitecore
If means the assembly you are registering can't be found.
12 Aug 2016 by misaqyrn9677
Can Fix It Just All Layer Must One Version Net FrameWork
10 Dec 2012 by demouser743
Is it possible to add an entity to a database. Initially I have updated a database from a model, now I created a new entity on the model, now I would like to add this entity to the database. How can I do thisInitial look of my edmx is as...
10 Dec 2012 by Prasad_Kulkarni
Check this answer if you get some help out:Click here[^]
6 Mar 2016 by Anatoliy Khotin (9682296)
Small application that allows text to be added to an image for annotation or to create greeting cards using ASP.NET MVC and jQuery
11 Nov 2017 by spankyleo123
Hi Folks, Would appreciate if you can help me out in my query below. I want to add values of consecutive list items into another object and retun a list of this object. var books = db.Books.Where(x => x.MembershipId == membershipId).ToList().orderBy(x=> x.BookName); The above returns the...
11 Nov 2017 by Karthik_Mahalingam
Try this Create a class with 2 property Public class MyClass { Public string Name {get; set;} Public string Status {get; set;} } Iterate the books list (with increment of 2 )to store the Value property in Name and Status as below List lst = new List(); For( int I =O; I
2 Feb 2013 by Darith1974
Can anyone inform of a link, video or tutorial which shows how to connect a entity framework database(Database first) to a wcf rest application in visual studio? What i have found so far is not very useful?
2 Feb 2013 by Joezer BH
Hi Darith, See Implementing a WCF Service with Entity Framework[^]Cheers, Edo
2 Feb 2013 by Krunal Rohit
http://blogs.msdn.com/b/writin...
8 Nov 2015 by Member 12063314
So I've got a project and I've setup the Entity Framework model in a folder called App_code. I've previously added 5 classes (tables) with no problem, but when I try and add the PostCodesUK and then compile I get this error:Error 1 The type or namespace name 'PostCodesUK' could not...
4 Dec 2013 by rajacsharp5
Hi frends,learning ef.small basic doubt is 1. i was added 2 tables and 1 stored procedure.later done=> right click on edmx file=> autocode generated. [done succes fully].now if i was added a table again that table was not added to the edmx .why.is there i have to do any...
13 Aug 2019 by Benktesh Sharma
Demonstrate how to add EF support in .NET Core project
29 Aug 2014 by Aashish vermaa
Hi,I need some help in the following seniors:1. I have a view page where I display around 10 records without using any filter condition. But after all the data bind on the page, user could search a particular record or filter record. How can I achieve this functionality using...
20 Jan 2011 by Gil Fink
Adding Metadata to Entities in The Data Model
8 Mar 2012 by Ole Morten Heien
Hi allI have a database with no constreains and no relations. This is just a converted flat-file database and must not be touched.I nead to create entities with relations and tryed this:[Table("Customers")]public class customer{ [Key, Column("CustoemrID")] public int...
26 Feb 2018 by jupemen
I try query with linq but I get the following error: The entity or complex type 'SELEXExpressCL.Data.TRUCK' cannot be constructed in a LINQ to Entities query. TRUCK truck = (from item in context.TRUCKS where item.NUMBER == TruckNo select new TRUCK() ...
26 Feb 2018 by F-ES Sitecore
You don't have to create a new TRUCK class, you already have the object you need in "item" so just select that TRUCK truck = (from item in context.TRUCKS where item.NUMBER == TruckNo select item).Single(); BTW I googled the error message and this was the first...
15 Aug 2013 by sajid zafar_Iqbal
hi all,i am using ado.net entity data model for my application with MVC database first approach. Now the issue is that whenever i tried to update my entity model by following these steps1 - right click on model designer2- update model from database3- Add tables 4- Finish The new...
22 Sep 2013 by blumoononline
1 - right click on model designer2- update model from database3- Add tables4- Finish----------------------------After doing above steps,5 . Right click on Model designer6. Add code generation item -> Select Visual c# -> Add New Model.tt fie (EF 5.x DBContext Generator)...
3 Jul 2013 by Narasima
Hi All,Please help me anybody on this.I am getting below error while save data into database.I am using Code firtst entity Framework.error is this. error on Updating record “An error occurred while updating the entries. See the inner exception for details.Model is ...
30 Oct 2009 by sarvesh.upadhyay
ADO.NET Entity Framework as Data Access Layer
11 Dec 2013 by Shivprasad koirala
Quick revision of 25 important ADO.NET Entity Framework interview questions with answers.
15 Apr 2016 by Amit-kumar-Amit-Kumar
Previous I was working on the Asp.Net(C#) with the ADO.Net Web Application, Now i want move on MVC 5. I am totally new in the MVC.I want to know which one is better in MVC 5, that ADO.Net or Entity Framework ?What I have tried:I have not perform any project with the use of MVC...
15 Apr 2016 by Richard Deeming
Which is better: a speedboat, or a Ferrari? *Without knowing the intricate details of your project, or your team's experience, capabilities and preferences, there's no way we can tell you which technology is "better". They're both pretty good, and both perfectly usable in ASP.NET MVC....
16 Dec 2010 by Vincent-Philippe Lauzon
Samples showcasing usage of OData in .NET (WCF Data Services); samples go in increasing order of complexity, addressing more and more advanced scenarios.
29 Apr 2020 by Member 11072126
Hello everybody, I am new into Entity Framework. Can anybody explain me the advantages of using EF over ADO.Net and the disadvantages of EF too, with the help of example?
27 Jul 2015 by OriginalGriff
We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.Try it yourself, you may find it...
1 Jan 2018 by Member 12824116
Advantages of Entity Framework The advantages of EF are given bellow: It provides auto generated code It reduce development time It reduce development cost It enables developers to visually design models and mapping of database It provides capability of programming a conceptual model. It...