Click here to Skip to main content
15,889,909 members
Everything / Entity Framework / Entity Framework 4.0

Entity Framework 4.0

EF4.0

Great Reads

by linush
Explains how to mock test an EF Model-First project using ADO.NET Entity Data Model template
by Dean Oliver
A performance tip for EF 4.1
by Ram Balak Sharma
How improve performance of EF
by Akhil Mittal
Code First Approach and Migrations in Microsoft .NET Entity Framework

Latest Articles

by Akhil Mittal
Code First Approach and Migrations in Microsoft .NET Entity Framework
by Jim_Gray
How I simplify my DataContext using Generics and OOP in C#.NET
by Rahul Pawar LogicMonk
Simple Demo Entity Framework - a tutorial explaining Code First!
by David Bywaters
Two approaches for unit testing Entity Framework

All Articles

Sort by Score

Entity Framework 4.0 

29 Aug 2012 by linush
Explains how to mock test an EF Model-First project using ADO.NET Entity Data Model template
12 Apr 2018 by Clifford Nelson
I am just getting started with Entity Framework and getting the following error in my code and would like to know how to proceed:Error 29 Error 3027: No mapping specified for the following EntitySet/AssociationSet - COUNTRies, PRHs. ...
20 Nov 2011 by Mehdi Gholam
I have found a possible solution here : http://www.dotnetmonster.com/Uwe/Forum.aspx/winform-data-binding/1042/BindingSource-Filter-fails-when-datasource-derives[^]
14 May 2012 by Vartan Khachatourian
hi expertswe have a static ip that comes to our switch and all servers are able to connect to internet.one of the servers is for sqlserver 2008 .i published our website to internet but i must use our local sqlserver because other local applications are connecting to it.but 2...
6 Jun 2012 by Zoltán Zörgő
What about:TelephoneExt = string.IsNullOrEmpty(c.PhoneExt) ? " ext. " + c.PhoneExt : string.Empty;
18 Aug 2012 by _Amy
This exception will obviously come when you'll try to point an object which is null.Try this:
20 Nov 2011 by Sander Rossel
Hi folks,I have been working with Entity Framework and binding for quite a while now. When suddenly the following struck me: A BindingSource has Sort and Filter Properties.These are only supported when the bound Object Implements IBindingList or IBindingListView. A standard List does not...
25 Jan 2012 by Dean Oliver
A performance tip for EF 4.1
4 Apr 2012 by Alberto Biasiutti
Well, it seems like It's all simpler than I thought. I can simply do:/*Example class Product*/public class Product{ public int id {get;set;} public string name {get;set;} public string category {get;set;}}//controller action for searchpublic ActionResult...
5 May 2012 by Vartan Khachatourian
Hi expertsI got a table in SQL Server 2008 has 10 columns and one of them is a computet column(([FirstName]+n' ')+[LastName])But when I try to insert a new object to the table with entityframework 4, it can't and an exception like computed column can not be nullBut if I remove the...
14 May 2012 by Zoltán Zörgő
A) You have one single static IP, and a router with NAT?If so: use static ip also on the intranet. Use local DNS server, or simply NetBios names of the server.B) You want to publish the SQL service to the internet?Dont do that! Allow only the front-end (web server) to be accessed from...
15 May 2012 by Vartan Khachatourian
hi expertsone sql server in localone asp.net application has been uploaded to internet.the application must use sql server. i got a static ip but i coudn't set web config and connection string. yes i searched google and i did several solutions.the application or solution has many...
6 Jun 2012 by AspDotNetDev
Clifford has the correct solution for the IsNull issue, but I thought I'd add an alternative way to parse the integer:if (!Int32.TryParse(Request.QueryString["id"], out pk)){ // The TryParse will default it to 0 on failure, // but I put this here in case you want to default to...
13 Aug 2012 by Wendelius
Check that the ExecuteNonQuery actually makes the insert. The method returns an int which tells you how many records were affected by the command. So in your INSERT the results should be 1 (one record added)Another thing you can check is that your connection string isn't pointing to an SDF...
23 Aug 2012 by pramod.hegde
Try this,string Agency = "";var query = (from c in context.tEmp where c.Agency.Equals(Agency) select c.Division).Distinct();This is equivalent to SELECT DISTINCT divisionFROM tEmpWHERE division= @AgencyBut query statement would execute only when you...
6 Nov 2012 by Rohit Shrivastava
Placing answer from comments:Quote:Instead of executing dynamic query write a static query with param, change to followingselect QID,Marks,Question from QBObjective where CASE WHEN @LevelID = 1 THEN 1SubjectID WHEN @LevelID=2 THEN 2SubjectID END = @TopicIDI am sure you have...
18 Oct 2011 by Dave Kerr
We'll need more information than you have provided.If you need to delete a row in the entity framework data model, it's like this:MyModel model = ;// your model.model.DeleteOject(myEntity); // the entity you want to deletemodel.SaveChanges(); // commit the changesNow when you say...
19 Oct 2011 by Ram Balak Sharma
How improve performance of EF
21 Jan 2012 by Namlak
Using EF4.2 and Code First (although I've had to deal with this sine Linq2SQL), I find myself coming across situations like this all the time:Label1.Text = MyEvent.EventType.Description;MyEvent is of type Event, and EventType is a navigation property.This works great unless the...
26 Jan 2012 by Dean Oliver
http://tomlev2...
16 Feb 2012 by nagsankar
in .cshtml page i have created table that consist large amount of columns and rows.i want to create scrollbar if anybody know please tell me.
16 Feb 2012 by nagsankar
..........
28 Feb 2012 by Odd_s
Using the entity framework and WPF I want to have a combobox that 1. populate the items from a list that I refer to in XAML. The list is defined in code. The list has two columns: “ValueCh” and “Text”.2. All the “Text” entries are to be shown in the dropdown list 3. The “ValueCh” is to be...
8 Mar 2012 by SwapnadipSaha
hi all, Recently I have joined an IT company. and I've to face an exit test next week on the following topics1. Basics of MVC2. Integration of Entity Framework, MVC, AJAX and Jquery3. Repositories4. Unit Of Work5. Unity Framework6. Data Manager7. Data...
3 Apr 2012 by Alberto Biasiutti
I'm developing an MVC3 and EF.4.1 application where the user must be able to perform "custom" searches.For example, I must be able to search activities specifing that they must be "my activities", or that they are activities for a "specific customer", or both.What I would like to know,...
15 Apr 2012 by Andy411
Hi all,First time I'm asking a question here. Hope I did it correct.I have an appliaction (WPF) which uses EF to connect to a database. My need is to detect changes of the database which are performed by external apps and then to reload the data in my application to be up to date. The...
16 Apr 2012 by Saed Leghaee
hiI think if you fill data from entity to list of type ObservableCollection and set the itemsource of datagrid to ObservableCollection list,your problem will be solved.
8 May 2012 by AbdulMuheet
Whats the main use of entity Framework introduced in 4.0, when we can achieve the same things using the normal store procedure and LINQ.
8 May 2012 by Ganesan Senthilvel
Let me put it in simple way. With the Entity Framework, you are architecting, designing and developing at a conceptual level. You are no more worried about the ‘specific details’ of communicating with the database and switching from one relational database to the other is also possible with EF,...
8 May 2012 by Deepak_Sharma_
Here are some FAQs about Entity Framework:http://www.dotnetcurry.com/ShowArticle.aspx?ID=599[^]
16 May 2012 by Clifford Nelson
You might check out this article:Implementing a WCF Service with Entity Framework[^]
10 Dec 2012 by mayankps
Microsoft has provided a cool feature for generating controller and views using scaffolding of templates and you can do it by just right clicking on the controller's folder, say add controller and add then can specify the data context class,modal and then select template and click on Add buttton...
6 Jun 2012 by Lakhwant
I am using ef4.0 I have a complex and big sp that return a data when normally used with enterprise library, but doesn't return any data when using with ef.here is the SP:CREATE PROCEDURE [dbo].[usp_SelectLocations_NotEmptyForTreeView] @RefrencePage int, ...
1 Aug 2012 by Oleksandr Kulchytskyi
i have resolved this issue by myself.The main reason , why this wont work , hide in realization of property:public string Speciality { get; set; } As concerns this property i have change it type to, see below:public IEnumerable Specialty { get; set; } and changed a bit my...
13 Aug 2012 by Anele Ngqandu
hi I am doing some basic insert to database.sdf file using tables from EF,all connections work but am having problems inserting,deleting,updating values to the database. Y is that?What am i misng?Code to insertstring strConnection =...
13 Aug 2012 by ridoy
First ensure your connection string is right that points your database.You used SqlDbType.NVarChar...so you need to ensure the text length limit of your textboxes.Instead of that you can use SqlDbType.VarChar.
23 Aug 2012 by Clifford Nelson
What you need to do is create a list of the names, which are strings. That gives you something to have that the distinct will work on. If you do a distinct on some object that contains the name, then you will get everything unless you overload the .var divisionNames = divisions.Select(d =>...
27 Aug 2012 by Matt T Heffron
With the following "dummy" data:var coll = new[] { new {Agency = "AA", Div="a", Val=0}, new {Agency = "BB", Div="a", Val=-1}, new {Agency = "BB", Div="b", Val=-2}, new {Agency = "BB", Div="b", Val=-3}, new {Agency = "AA", Div="a", Val=-4}, new {Agency = "AA", Div="c",...
23 Aug 2012 by Prabhakaran Soundarapandian
try this IList OrgName = context.tEmp.Where(p => p.Agency.Tolower() == AgencyTolower()) .ToList() .Distinct();
20 Sep 2012 by Brian C Hart
I am just starting out with my first Entity Framework project built from scratch, to teach myself. I have encountered EF projects before at work but they were already pre-built by the time I had come along so I just had to tweak and maintain them, never build a EF project from the ground...
25 Sep 2012 by ASP_DIV
Hi,I'm working on MVC3, Entity framework architecture. I use dataTable.js to assign an HTML table and display data as rows-columns with expand/collapse on the rows.Using fnAddTr plug-in, I add a child row, on click of '+' sign of parent. The parent as well as the child row has 14...
3 Oct 2012 by a_behzadi
I moved membershiptables to my database by using aspnet_regsql.exe. Then I created a table named "Article" and needed to save the user id of the article`s author in "Article" table. So I added a column with name "Author" and type uniqueidentifier in "Article" table and then created a relation...
10 Oct 2012 by iceball12
I have code first models with the latest 6.6.x beta driver working.Dbmigrations seem to be working fine as wel.However there seems to be a problem with cascade settings.My models have cascade delete all over them, but the database that gets generated does not reflect these...
23 Oct 2012 by Zia Ullah Khan
how can we do insertion/retrieval with simple classes while having no database at hand.i want to hook the database after getting the working db, EF related ideas will be appreciated.thanks
4 Nov 2012 by snsrkrishna
Here is my SP alter PROCEDURE PopulateAllObjectiveQuestionsByTopic @TopicID dtid as SET NOCOUNT on begin Declare @LevelID varchar(10) select @LevelID = substring(@TopicID,1,2) declare @SQLString varchar(max) select @SQLString = 'select...
7 Nov 2012 by hemantwithu
I am a newbie to POCO.I have two tables like tb1 and tb2.Suppose we have a PK and FK relation between these tables.When it come to POCO CF how can we manage this relations?I have a done a sample by following a article. public abstract class Person { public string Name { get; set;...
4 Dec 2012 by Oleksandr Kulchytskyi
Hi guys,I have come here with one question related to EF 4.3.1.In my domain model I have 2 models: User and Message, each one has a primary key, called Key.After some analyzing process I have figured out, that I need to provide some additional funcions to represent messages, were read by...
4 Dec 2012 by Oleksandr Kulchytskyi
I have successfully resolved such problem.The crucial moment here was in creation of many-to-many relationships between this domain entities.So as a result i have injected to each concrete domain model property(collection of related entity).For example, in domain model of Message i have...
18 Dec 2012 by Jameel VM
Use T4 TemplateT4 is a general-purpose templating engine you can use to generate C# code, Visual Basic code, XML, HTML, or text of any kind. The first step in using T4 is to create a template file, which is a mix of literal text, code, and processing directives. The T4 template processor will...
8 Jul 2013 by Gautam Raithatha
Hello,I am using Entity Framework 4.0 and following issue occurs while updating objects (rows) in database:I have two related tables, say A and B, with A being the master table and B foreign table. Now in my C#.NET application, I make changes from front end and save it. In save...
15 Aug 2013 by atulggn
Hi All,We are facing some issues in making a left outer join between custom list to entities.Here is the code we are trying to implement:public class custd { public int BatchReportFileId { get; set; } public string UserName { get; set; } ...
2 Sep 2013 by Tammam Koujan
You can use the DynamicQuery libraryhttp://www.hanselman.com/blog/TheWeeklySourceCode48DynamicQueryableMakesCustomLINQExpressionsEasier.aspx[^]
7 Sep 2013 by Nguyen Tuan
I'm writing a Windows application (.NET 4), SQL Server 2008 and EF 4.0:Table "Currencies" in SQL Server is:ID smallint (auto increment) PKName nvarchar(100) NOT NULLCode nvarchar(10) NOT NULLRate float NOT NULLIsAfter smallint NOT NULL (Default Value = 0)Window Form...
29 Oct 2013 by Wamuti
I created a database model from MySQL to Visual Studio 2010. However, in the EntityObject's Create, for a table such as exam which has 9 columns, i only have two parameters (the key columns primary [id_exam], and foreign[user_id_exam]). Why could the rest be disappearing to what can i do about...
21 Feb 2014 by RonnieDean77
I have been digging all over the internet trying to find how I can get data from a complex query using EF. Is this even possible? using (var entity = new ApsAppsConfigEntities()) { const string myQuery = @"select comenv.[Name], catcon.[Key],catapp.[Key], conenv.Id " +...
22 Aug 2014 by Member 10978088
Hello there, I admit I'm a bit lost in all that read and see on the internet. So I'm developing a windows form application (sales management application) incorporating WCF to create a Web service that permettrais at my desk application to communicate with a given database (SQL SERVER)....
23 Aug 2014 by Raul Iloc
1.Your database module should be implemented into a library project (ASP.NET is a user interface project for web application) and if you want you could use ADO.NET for accessing the database, or you could use Entity Framework.Here is an article that you could use it as starting point for...
7 Oct 2014 by Sander Rossel
Hi all,I'm having a little trouble with using some Stored Procedures in an Entity Framework 4.0 model. I'm using Visual Studio 2010 and .NET/EF 4.0 and I have a SQL Server 2008 database.So in my database I have a couple of SP's;A1.MySPB1.MySPB2.MySPYou might guess the problem,...
31 May 2015 by gunkrr
i have this method to update 2 tables (parent and child) :public override void Update(ArCollectiveBilling entity) { var existingEntity = (from e in Entities.Include("ArCollectiveBillingLines") where e.CollectiveBillingId ==...
28 Jun 2015 by praveenlob7
//I have the following methods. I want to query a table data by using the output i got from previous query. I tried the below code but data does not load.private void btnFetch_Click(object sender, RoutedEventArgs e) { ctx = new Context();//Data loads here ...
4 Aug 2015 by Maciej Los
Please, read my comment to the question.The answer to your questions you'll find here: Entity Framework[^].As to your concern: MSDN wrote:With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented...
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.
12 Dec 2015 by marcosantana
Go to Solution Explorer, click the Search button, leave checked both "Search within file content" and "Search External Files", type the entities name your mapping isn't recognizing. Delete all files RELATED to the problem. Those will probably be named after the same missing entity. DO NOT delete...
19 Sep 2012 by David Bywaters
Two approaches for unit testing Entity Framework
15 Nov 2015 by Rahul Pawar LogicMonk
Simple Demo Entity Framework - a tutorial explaining Code First!
21 Apr 2012 by Kelvin Armstrong
Entity Query Load Manager for Entity Framework Domain Contexts.
29 May 2012 by Wael Al Wirr
Sometimes if you make any changes to the EDMx file or if you change a database column and do an update the mapping xml representation for the EDMx file gets corrupte and you receive this error. just click control + A delete all objects in the EDMx file and add the database again, or you can open...
6 Jun 2012 by Clifford Nelson
var query = ( from c in context.tEmployees where (c.pkEmployee == pk) orderby c.NameLast, c.NameFirst, c.NameMiddle, c.Agency select new { Name = c.First + " " + c.Last, Telephone = c.Phone , TelephoneExt = c.PhoneExt != null ? " ext. " + c.PhoneExt :...
19 Apr 2012 by Federico Colombo
How to replace textual properties of EF Objects with translations
18 Aug 2012 by Kuthuparakkal
string conString = ConfigurationManager.ConnectionStrings["connString"].ToString(); is sufficient. Plz try...
8 Feb 2012 by akhil khare
The Underlying Connection Was Closed: The Connection Closed Unexpectedly in EF 4.0
2 Mar 2012 by akhil khare
The-underlying-connection-was-closed--The-connection-closed-unexpectedly-in-EF-4-0
3 Apr 2012 by Sander Rossel
Oops... I just noticed you are using ASP.NET and I linked to WinForms Controls... This doesn't matter for the idea though. I just put the links there as a reference, you shouldn't need to click them if you know your trade ;)Not sure what you are trying to achieve exactly, but it...
7 Jun 2012 by JChrisCompton
I have a results page that displays a single record.Question:If there isn't a phone extension, how do I exclude (suppress) the phone extension itself and "ext." label from the returned data?If there is an extension I want:• Chris Compton 919-754-6000 ext. 6512...
30 Jul 2012 by Oleksandr Kulchytskyi
Hi guys, who can help me with definition of LINQ query.I've got a simple entity:public class PhysicianInfo2 { public PhysicianInfo2() { foreach (System.Reflection.PropertyInfo info in this.GetType().GetProperties()) { if...
27 Aug 2012 by JChrisCompton
I need to convert this to a distinct query. So far all efforts have failedstring Agencyvar query = ( from c in context.tEmp where (c.Agency.Equals(Agency)) orderby c.Division select new { OrgName = c.Division });This returns each division multiple...
11 Feb 2014 by Kornfeld Eliyahu Peter
Read here:http://code.msdn.microsoft.com/windowsdesktop/CSASPNETUniqueConstraintInE-d357224a[^]
6 Sep 2017 by Jim_Gray
How I simplify my DataContext using Generics and OOP in C#.NET
23 Aug 2012 by Christian Graus
context.tEmp.W...
27 May 2012 by Madhukar Mudunuru
try using Dynamic Data Entities framework.You can generate Entities and screens are generated using scaffolding.
15 May 2012 by mariazingzing
1. EF doesn't matter. Set IP in Web Config: source = tcp:,for ex: tcp:11.223.2.1,11432. no any problem. when you publish the website it handles all resourced
3 Aug 2015 by Member 11873526
I have heard and read a lot that EF is the fast way to connect and insert data into SQL table and it eliminates most of the code to connect with SQL. But we take the example of Large BFSI application where we have to have write all business logic inside the SP only. As i have read, EF directly...
18 Oct 2011 by jayanthik
How to delete a row in gridview using entity framework 4.0. The row is not deleting and this is my code: protected void DeleteRecord(object sender, GridViewDeleteEventArgs e) { tbl_emp objempdelete = new tbl_emp(); //int empId =...
20 Sep 2012 by Brian C Hart
My solution was found in the post here:http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/ab2dd9f9-1eda-4d4e-a0c0-d1f1964343f7[^]It says to put the section after the section and I also renamed the connection string to match the name of the auto-generated...
24 Oct 2012 by Ajay Bachale
Use nHibernet. I will create a tables in db automatically.
24 Oct 2012 by fjdiewornncalwe
What you are looking for is Entity Framework in a fully disconnected environment.Finally! Entity Framework working in fully disconnected N-tier web app[^]
1 Sep 2013 by shadowrad
Hi I need to find data in a table by one or all properties, my idea is to fill an entity and make a search by all properties if the parameter is not nullI have 2 ideas for this but i dont know if is posible for both cases. If there is a better way im all ears too :PThanks and...
11 Feb 2014 by Wamuti
Hi all.I am creating a database which has a table called Faculty. The Faculty table has a column called FacultName (it is not the EntityKey). However, I would like to ensure that despite FacultyName not being a key attribute, a faculty name cannot be entered twice. How can I set this...
15 Aug 2014 by Shiva nag
I have cascading dropdownlist which is working fine but I have one more dropdwn with in the page I need to bind it using how? I am using EF