Click here to Skip to main content
15,892,005 members
Everything / Entity Framework / Entity Framework 5.0

Entity Framework 5.0

EF5.0

Great Reads

by S. M. Quamruzzaman Rahmani
ASP.NET team released Identity framework 2.0. The new release contain some new features like generic primary key. This article explain how to change primary key from string to integer & use it with MVC5.
by Dukhabandhu Sahoo
Know how to exclude types from the Model in Entity Framework Code First
by Tom Cook (UK)
How to asynchronously poll a database for an Entity with EntityFramework 5
by Dileep Ashok
Configure Many-To-Many Relationship and ListBox control in MVC and Entity Framework

Latest Articles

by Akhil Mittal
Code First Approach and Migrations in Microsoft .NET Entity Framework
by Sherjil_Ahmed
Mixing DB-First and Code First Approach for using SPs in EF-Way
by Wahid Bitar
Validated the unique constraints at dbContext ValidateEntity in a generic way by reading the IndexAttribute values.
by Nathan Minier
Generic AddOrUpdate for EF with composite key support

All Articles

Sort by Updated

Entity Framework 5.0 

18 May 2015 by .net bigner
namespace tableshow.Controllers{ public class TableShowController : Controller { private TableShowEntities db = new TableShowEntities(); public ActionResult show() { ViewBag.TableShowsData = db.TableShows.ToList(); return...
28 Jul 2014 by _Amy
I'm adding few more links in above solution:MSDN : join clause (C# Reference)[^]SQL Joins with C# LINQ[^]C# Join[^]--Amy
22 Feb 2015 by _Maxxx_
I think, to me, the Person controller needs to handle this.A Person needs to know about a Phone - but a Phone needs no knowledge of a Person.So your phone controller shouldn't need to know about Person at all.
19 Sep 2014 by Aashish vermaa
Hi,I have some tables in my database and want to insert records in these tables using Entity framework in MVC 4.0.Insertion took place in this way that insertion of record in child table depends on the records in the master table.This functionality could be achieve easily by Transaction...
28 Sep 2014 by Aashish vermaa
Hi,I have a table which contains some data.This table has a column which contains data with HTML tags.But the scenario is this:1. This column can not have same values.2. When a user comes second time to insert new record then it first check the new value with existing value to...
28 Sep 2014 by Aashish vermaa
Hi,I want add auto search feature on a CSHTML page.When a user type in the textbox then values got from database should be bind in a table on the CSHTML page.It should filter records base on the value type by the user in the textbox.It should keep filtering the records when user...
16 Mar 2014 by Abhinav S
TryJoin Query using Entity FrameWork[^]Left Outer Join extension for Entity Framework[^]
9 Aug 2014 by Abhinav S
These might help - https://documentation.devexpress.com/#WindowsForms/CustomDocument1477[^]https://documentation.devexpress.com/#WPF/CustomDocument6094[^]You might also want to check DevExpress forums.
22 Apr 2015 by Abhinav S
You can use tinyint[^] or char[^] to store 0 and 1. An alternate could also be to use a bit[^] type.Here are some examples on create a dropdownlist in a view - DropDownList / Basic usage [^]DropDownListFor with ASP.NET MVC[^]
27 Jun 2015 by Afzaal Ahmad Zeeshan
Database server (SQL Server) is a stand-alone application that doesn't have to rely on anything to provide you with data, apart from a few factors such as latency rate etc. So that is why, executing the command (SELECT) would take only 1 second. Whereas WCF on other hand has to depend on...
22 Jun 2013 by ahmed.sharu
Dear All, I want to know the best implementaion of MVC with EF5 for the next sample if we have a view like this@model...
22 Jul 2014 by Akhil Mittal
How can I switch between multiple databases using Entity Framework.The name of the databases will be coming in a drop down list and on selecting the dropdown list item I need to connect to that particular database using Entity Framework.What is the best solution? Do EF provide any...
3 Apr 2014 by Alcides Melo
I want to drop some tables and create again following my models design. But the CodeFirst never do it, keeping trying to apply the changes that I did, but for some reason he can't. The Designs of models class is ok but the tables on SQL is not and thats why and want to drop and recreate again. I...
27 Nov 2012 by Alex_Xia
A simple introduction for beginner to jump start on Entity Framework. The Model and query language are explained.
1 Dec 2014 by Amit Kumar143
i created a wcf web service. my service uses EF5 data acceess to fetch data.i have only one function named GetAllAdminList() code: IAdminService.cs public interface IAdminService { [OperationContract] List GetAllAdminList(); }And...
23 Aug 2015 by Andy Lanng
I hope I have this correct:They way you propose to do this is not a good idea, but there are ways to achieve the same end result that are a good idea.Take a look at this://Generic Factory (Reflection)//Specify the worker and the return typeList addresses =...
7 Feb 2017 by Andy Lanng
It sounds like you actually have a many to many relationship. This requires a link table which contains a foreign key for both products and tags. Each product can be inserted without constraint and each 'new' tag can be inserted without constraint. when you know which tags should be hooked up...
12 Mar 2013 by Andy411
Some steps you can go to analyse your problem:1) Implement a simple test method in your WCF service, e.g.public in TestMethod(int data){ return (data + 1);}and look how long it takes to call it from your client.If it is fast enough, your next steps would be to see...
8 Sep 2014 by Animesh Datta
Try this wayList = dbcontext.content.ToList().Where(u =>(Convert.ToDateTime(u.Date).Month==M_no) || (Convert.ToDateTime(u.Date).Year==year_no) || (Convert.ToDateTime(u.Date).Day==day_no)).ToList(); example will demonstrate the properties .System.DateTime moment = new...
4 Mar 2016 by AshishvermaMCA
How to pass n number of parameters to Stored Procedure(SP) in Entity Framework What I have tried:I have not any idea because in EF dynamically mapping is performed.So how can pass n- number of parameters in SP
23 Oct 2015 by Asmaa Rashad
Hello ,iam working using MVC and Entity framework , I have a view that displsy data of "BloodDonors" table from database and i can filter them by their blood group value that selected by dropdownlist ,so i want after choosing specific blood group i call the controller function that filters and...
11 Jul 2014 by awaisshabir
error message:'System.Web.HttpContext' does not contain a definition for 'SaveChanges' and no extension method 'SaveChanges' accepting a first argument of type 'System.Web.HttpContext' could be found (are you missing a using directive or an assembly reference?)code...
2 Oct 2014 by awaisshabir
how to create database connection string and how to pass connection string runtime in entity Model?
14 Sep 2014 by Bastien Vandamme
I'm building a project with Entity Framework and MySQL. For compatibility reason I need to use Entity Framework 5. I did a little mistake and updated my Entity Framework to version 6.1.1 with nuget package manager. I would like to uninstall this version 6.1.1 to use the version 5. Is it possible?
15 Sep 2014 by Bastien Vandamme
I have a solution with 3 projects. - one for Entity framework that contains my edmx diagram (App.Config) - one for my core business (App.Config) - and one for my web API (Web.Config)When I publish my project on my hosting service or my personal server I also...
20 Aug 2014 by baswaraj.s
Following Is my Error while i Edit, Update the record..."The model item passed into the dictionary is of type 'IkkosAdminPortalWebSite.RecordDetail', but this dictionary requires a model item of type 'IkkosAdminPortalWebSite.Models.RecordDetails'."In this RecordDetails---ModelClass,...
27 Jan 2013 by bilalmix
hello everyone the new entity framework 5 use dbContext generator so my problem is when i use MVVM patern i need to implement INotifyPropertyChanged interfacein all my entitys and that will tak alot of time , and some ome one told me to use Object Context generator .......
9 Apr 2013 by Brian C Hart
I am using Visual Studio 2010, SQL Server 2008 R2 developing on Windows 7 Ultimate. I am using .NET Framework 4 and C# to develop a WinForms application that interfaces to an existing SQL Server database using Entity Framework 5 Code First technique of reverse engineering the DbContext and...
10 Aug 2016 by bubai banerjee
In my MVC application,i want display result (when i enter the application no in Id textbox,it will display the customer FirstName,LastName,Address in respective textboxes instead of displaying it in webgrid,in the same page by using EF.i am using mvc4,visual studio 2012 and EF.Thanks in...
9 Aug 2016 by bubai banerjee
In my MVC application,i want display result (when i enter the application no in Id textbox,it will display the customer FirstName,LastName,Address in respective textboxesinstead of displaying in webgrid,i want to display record in the same page by using EF.i am using mvc4,visual studio...
27 Aug 2016 by bubai banerjee
I am developing a asp.net MVC application.Here i want to display 15 mins time interval and one textbox displayed each time for that particular day.Example:Time Activity10.00am Go for Breakfirst10.15am return for Breakfirst10.30am Back to study10.45am write...
2 Jun 2013 by chrisndirangu
Hi I have this class;[Table("tblRegions")] public class Region : MasterEntity {public string Code { get; set; }public string Description { get; set; }public Region ParentRegion { get; set; }public Country Country { get; set; }public RegionType RegionType { get; set; } ...
17 Aug 2014 by Christian Graus
You could try to put classes in to dlls if you really wanted to, but it's not a good idea. You can select to 'publish' your site to a local folder then copy that folder to the target machine.
25 Jun 2014 by Christof Senn
You might be interested in using the open source N-Tier Entity Framework[^] which uses Entity Framework on server-side and generates the entire infrastructure for building an n-tier architecture based on WCF including an EF-like API on client-side for both, Silverlight and .NET
2 Apr 2014 by Code Help 2014
Check the below page for details:DataBase Update error in Entity framework.[^]
24 Nov 2014 by DamithSL
check Code-first vs Model/Database-first[^] based on the comparison you better decide which is bes for your case.
11 Oct 2013 by Dave Kreskowiak
The first question is Why?? Since you're making a new Person object, nearly everything will be a change. The only things that won't will be the default values for your object property types, like 0 for an int.
5 Apr 2014 by Dave Kreskowiak
Google for "entity framework 5 code first migrations" and you'll find what you're looking for.
16 Apr 2014 by Dave Kreskowiak
Uhhh, this may seem like a stupid response, but did you try supplying the required information it wants??It appears as though you're trying to use entity models in the place of a view model.
19 Sep 2012 by David Bywaters
Two approaches for unit testing Entity Framework
2 Mar 2015 by deepak690
i am using transaction scope in my project. Isolation level is IsolationLevel.ReadCommitted i Also tried IsolationLevel.RepeatableRead using (DBOperations dboperation = new DBOperations()) { GetAccountVoucherNuber(); }i am calling this method from Transaction...
18 Jun 2015 by deepankarbhatnagar
Hi, try this,from f in foo join b in bar on f equals b.Id into bs from b in bs.DefaultIfEmpty() where b.Pid = 10 and b.Sid = 20 select new { Name = f.Name, Id= f.id == null ? "Null" : f.id};Thanks in advance
20 Feb 2013 by DeepsMann
Hello,I am using EF 5.0 and Code first approach in my project.There are 10-15 tables in my database, and I have two context classes.Now, for slow start up I have read a lot of articles and blogs. I found that installing EF power tool will allow me to generate views which will help in...
12 Mar 2013 by DeepsMann
Hello,I have a WCF service hosted on IIS 7.5 on my server. I have used Entity framework 5.0 in my service.When I call that service from my local system by adding service reference and creating client in a site, it takes approx 40 seconds to get the response. I tried calling the same...
28 Dec 2014 by Dhaneshmon
I am very new to ASP.Net MVC. I am planning to create on website for classifieds. So I would like to get url as following(http://mysitename.com/stateName/Place/Furniture/34)From admin panel I should able to create StateName,Place, Category(eg. Furniture)I am planning to start...
5 Aug 2014 by Dileep Ashok
Asp.Net MVC-4,Entity Framework and JQGrid Demo with simple Todo List WebApplication
5 Apr 2015 by Dileep Ashok
Configure Many-To-Many Relationship and ListBox control in MVC and Entity Framework
7 Feb 2017 by Dishant Arora
Hi,I have two tables one is product and second is tags. They have their respective columns. There is one to many relationship between product and tags. One product can have multiple tags(This has to be done using Database, no Javascript). So, I have included Product key as foreign key into...
8 Nov 2013 by Dotnet Specialist Hasnain
I have facing a problem,I have set session time out in web.config
1 Oct 2014 by Dukhabandhu Sahoo
Handle optimistic concurrency using Entity Framework Code First.
12 Oct 2014 by Dukhabandhu Sahoo
Know how to exclude types from the Model in Entity Framework Code First
14 Oct 2014 by Dukhabandhu Sahoo
Learn how property is automatically mapped to column and how to manage it in entity framework code first.
16 Aug 2015 by durgaprakash
While calling Stored procedures from Entity framework 6.1.3, we are getting the error below...Entity Framework EF6.1.3 - stored procedure, “The FunctionImport '>' could not be found in the container '>'.”
8 Mar 2013 by E.F. Nijboer
It is just the starting point. With EF you already have a database and EF will extract the object models for you. With code first you create the object models and it will create the tables for you.Code First with Entity Framework 5 using MVC4 and MVC Scaffold[^]Good luck!
31 Aug 2012 by Eduard Keilholz
Hi,I have a question about Entity Framework 5. I generated this nice model from my (MS SQL Server) database, for example a table called 'User'. The table contains not nullable fields.Now in the old(er) versions of EF, objects would be generated with a static CreateEntityName function. In...
16 Apr 2014 by EduChapow
There's my Model, and i can't Edit it.The errors on my ModelState returns:var errors = ModelState.Values.SelectMany(v => v.Errors);[0] - "The Field Name is Required."[1] - "The Field Id is Required."[2] - "The Field Name is Required."public class Document { ...
4 Apr 2014 by Er. Puneet Goel
Just Start from this : Entity-Framework-Sample-Application-for-Beginners
6 May 2014 by Eric Goedhart
4 Aug 2015 by F-ES Sitecore
You can still call SPs using Entity Framework, but if your system contains all of its logic inside SPs then I personally wouldn't bother with EF. EF is more for if you simply have a well-defined relational database and you want to query the database at a code level rather than an SP level.
7 Jan 2013 by fernando albernaz
How to do a polymorphic association like Rails using Entity Framework
4 Mar 2016 by Frank Kerrigan
Pass raw SQL to EF[Entity Framework Raw SQL Queries[^]]
11 Jul 2014 by Gaston Verelst
Hi,In your last line you refer to Context (with uppercase) instead of context (with lowercase). These are 2 different objects.HTH,Gaston
6 Apr 2014 by Gaurav Gupta A Tech Guy
how to bulk insertion in MVC 4 with EF 6 ?
29 Jun 2014 by George Jonsson
It should be possible to use the DataAdapterDbProviderFactory factory = DbProviderFactories.GetFactory("Your database provider name");DbDataAdapter da = factory.CreateDataAdapter();DbCommand cmd = connection.CreateCommand();cmd.CommandType =...
3 Oct 2014 by George Jonsson
You can look up connection strings on this site: The Connection Strings Reference[^]
17 Jun 2015 by gunkrr
I'm using Entity Framework 4.1When i update entity (has child table with 50 data), it will be long timeCause of EF will send 50 delete query and 50 insert query to child tablethe example code is below : var existingEntity = (from E in Entities.Include("GoodReceiptItems") ...
29 Oct 2013 by gwyder
HiI want to map this SQL table, named Media, using EF 5.0 CodeFirst, through DataAnnotations or Fluent. [MediaID] INT NOT NULL PRIMARY KEY, [Name] VARCHAR(100) NOT NULL, [ArtistID] INT NOT NULL, [ReleaseDate] DATE NULL, [Rating] INT NULL, [Price] FLOAT...
14 Jul 2015 by Hector Menchaca
Hello,Maybe at the moment of doing the render of your page you are not using the List class..I found this article and I think it can helps.http://stackoverflow.com/questions/27378288/but-this-dictionary-requires-a-model-item-of-type-system-collections-generic-ie[^]Best Regards!
21 Feb 2015 by i_syed2000
Assume, I have the following entity set below.Phone(PhoneId, PhoneNumber) Person(PersonId, FirstName, LastName)Company(CompanyId, CompanyName)Broker(BrokerId, BrokerName)PersonPhone(PhoneId, PersonId, PhoneType)CompanyPhone(PhoneId, CompanyId, PhoneType)BrokerPhone(PhoneId,...
8 May 2014 by ilaya muthumanickam
private List GetAllFieldValues(string p){ List field_values = new List(); string connectionString = ConfigurationManager.ConnectionStrings["SchoolContext"].ConnectionString; using (SqlConnection con = new SqlConnection(connectionString)) { ...
11 Nov 2015 by İlker Eker
While using EF you should use tables with a primary key. And while importing views, view should use the Primary key itself.
20 Aug 2014 by Jameel VM
You should return the type IkkosAdminPortalWebSite.Models.RecordDetails because the view is expecting model @model IkkosAdminPortalWebSite.Models.RecordDetails but you are returning the type IkkosAdminPortalWebSite.RecordDetail in the edit controller. So before you return the type set all the...
3 Nov 2014 by Jameel VM
You should create one more class Normally it say's Viewmodel .Whatever the properties you want to display in one view merge to one class.public class YourViewModel{//put all the properties from both classes[Display(Name = "Able to chat while riding")] public string...
19 Oct 2014 by je-wo
I use the entity framework to create a database and and the data access layer. All seems to work fine, but now I do have a problem I am not able to solve. It seems I didn't understand something. If I create an entity A and an entity B I do get two classes Aset and Bset. If they do have a...
19 Jun 2013 by Jitendra.Jadav
Hello,I am working on login, but WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe)is always give me false I had created the Context and this will working fine but once I try to login it always give me false result..even I had added webpages_Membership...
5 Jul 2013 by Jitendra.Jadav
Hello,I have developed application in MVC 4 and EF with WCF I have created menu into _Layout page so now I am want to login with valid user so that I can authorize the access but I am not able to use Websecurity.Login it always show me false..second thing I didn't some other scenario with...
5 Jan 2014 by JoCodes
You have to set the Principal - Dependent associations using either Data Annotations or through fluent API. Means, if its 1:1 use Required annotation or 1 - 0..1 need Optional.Refer...
24 Nov 2013 by John Korondy
It shouldn't be this hard! I am about to give up on EF...My model has weekly newspaper Editions. Each Edition can have many Classifieds. Each Classified can appear in one or more Editions. My models:public class Classifieds{ [Key,...
24 Nov 2013 by John Korondy
The problem was that EditionModel was not part of the context. Thank you, Slauma for pointing me in the right direction. The corrected Create Action is:...classifieds.Editions = new List();foreach (var p in EditionList){ var ed = await db.EditionModel.FindAsync(p); if (ed ==...
1 Aug 2013 by John-ph
Check this article, It has something "Dealing with database changes" that you are looking for in Database first approach[^]
24 Oct 2014 by johntallon
The problem is the location of where you are uploading the files to - App_Data folder. This is a designated folder and not usually accessible over the browser. Its for data and configurations and designed to be restrictive. You need to save the files into another folder:...
24 Jul 2013 by josh-jw
Hi All, In my application i am using database first approach with EF .so after creating entity model , i added a column to table. now i want that column in my model. hoe we can do this programatically.
14 Nov 2013 by Juan Davel
Do you absolutely need to use InProc? I suggest you either use (a) Session State Server or (b) SQL Server to manage your user sessions. I have not had one client complain about their session expiring after leaving their computer for 10-20 minutes, and we are using SQL Server to manage the user...
22 May 2014 by kannankeril
This article focuses on database first development using ASP.NET MVC. It uses the Northwind database and walks the reader through developing a CRUD application, applying annotations, custom styling and using the jQuery UI Accordion to deliver a more polished UI experience.
29 Apr 2015 by Karthik_Mahalingam
add System.Linq.Dynamic.cs [^] file to your solution and use the below code to do dynamic order by references : dynamic-query-library[^]static void Main(string[] args) { List list = new List(); list.Add(new Pupil() { Name = "b"...
28 Jul 2014 by kave2011
I have a table like belowBit AIdtrue 1false 1false 2true 2true 1false 3true 1false 3false 1true 2true 1true 3false 3true 2suppose corresponding entity for above table is A.I want a query entityframework method based that it subtract count of true from...
28 Jul 2014 by kave2011
I want to use left outer join for below tablesEntity1 in belowid A1 102 123 -24 105 56 37 38 5And Entity2id123456789101112Outputid A1 102 123 -24 105 56 37 ...
8 Sep 2014 by kave2011
I want to use GroupBy for DateTime Without (Hour and Minute and Second).I want to use only Year and Month and Day...how I use MethodBased Linq for this work.suppose My table Like below ViewDate 3/3/2012 01:03:12 1/1/2012 10:43:23 1/2/2012 09:12:12 3/3/2012...
8 Sep 2014 by kave2011
I solved itvar q = _db.ArticleViews.Where(m => m.ArticleId == ArticleId).GroupBy(m => new { m.ViewDate.Year,m.ViewDate.Month,m.ViewDate.Day }, (ViewDate, ArticleId1) => new { ViewDate, CountInDate = ArticleId1.Count(), });
3 Sep 2014 by kbrandwijk
I have seen some issues before with |DataDirectory| and ClickOnce deployment. See the suggestion here: http://stackoverflow.com/questions/19252480/invalid-value-for-attachdbfilename[^] to replace the |DataDirectory| during deployment.This is the code in VB.NET (from the link provided):Dim...
24 Nov 2014 by King Fisher
I have Entity Data model using auto generate from database.Now, I want to Add another table in Entity Data Model .I Right Clicked the .edmx file added Update model from Database and selected my table .everything fine.i see my new Table in Layout Diagram but when i add new Controller...
24 Nov 2014 by King Fisher
I'm gonna create a new MVC Application. which is best EF Code First ? Model First? Db First ? I don't have fixed Database Design ,i may modify existing table may add new table . so which one is Suitable for my Requirement
11 Feb 2014 by Kornfeld Eliyahu Peter
Read here:http://code.msdn.microsoft.com/windowsdesktop/CSASPNETUniqueConstraintInE-d357224a[^]
8 Mar 2015 by Kornfeld Eliyahu Peter
Please read this[^] to understand how to access controls inside a template...
11 Nov 2015 by Krunal Rohit
Take a look at this article,Performance and the Entity Framework[^]Gogle[^]And it may be urgent to you but not to us. People will provide solution when they can. So remove that "as soon as possible" from your question.One more thing, have a habit about researching about your query and...
5 Dec 2013 by Lakhan Aanjana
First tableMyidUidStart_DateLast_loginLastwall_sendLastmatch_foundScoreNamesecond TableMyidUidFidSubjectMessageStar_DateRead_messageRead_Dati want to all the message i want name from firsttable using fid whhich is uid in 1st table in...
9 Jul 2015 by Laurentiu LAZAR
Hi,I have the following Views hierarchy:_Layout.cshtml -> @model JobShop.Models.IndexVM -> is ok |_ @{ Html.RenderPartial("_LeftSlider", Model.AspNetUsers); } -> nothing here -> is ok |_ @RenderBody() for Home (Index) -> @model...
2 Apr 2014 by laxmi smiley
Enable-Migrations -ContextTypeName mvcSample.Models.Carti enabled migrations for cart.cs.migration folder with configuration is generatederror in updation.i tried Update-Database -configuration mvcSample.Models.Cartand error is:The project 'mvcSample' failed to build.please reply me
13 Jul 2015 by lokopi.nagar
I am building a registeration form, i am having problem in which class should i bind my index view to i am having three classes Districts, Tehsil, Subtehsil, which basically implement the cascading dropdownlist in the same order.public partial class District { public District()...