entity-framework-5

Entity, dealing with large number of records (> 35 mlns)

夙愿已清 提交于 2019-12-04 12:50:22
We have a rather large set of related tables with over 35 million related records each. I need to create a couple of WCF methods that would query the database with some parameters (data ranges, type codes, etc.) and return related results sets (from 10 to 10,000 records). The company is standardized on EF 4.0 but is open to 4.X. I might be able to make argument to migrate to 5.0 but it's less likely. What’s the best approach to deal with such a large number of records using Entity? Should I create a set of stored procs and call them from Entity or there is something I can do within Entity? I

Should we use Data Repository pattern in MVC application using Entity Framework Code First approach?

不想你离开。 提交于 2019-12-04 12:37:20
I have developed many application now with Entity Framework Code First approach. In all of the I use Data Repository pattern. This Data Repository pattern queries over single entity at a Time. for e.g, I have 2 models Employee and Department So to fetch all employees and department I would create 2 data repository instances. e.g var empRepository = new DataRepository<Employee>(); var allEmployees = empRepository.GetAll(); var depRepository = new DataRepository<Department>(); var alldepartment = depRepository.GetAll(); Now, This pattern works great in most of the case. Now, When I want to

How to execute raw sql query with in entity framework?

我的未来我决定 提交于 2019-12-04 12:22:30
问题 I'm using asp.net mvc 3 with entity framework 5. I have my .edmx file & able to interact with my database using linq or SP, but I want to run some raw sql statement. I'm trying something like this: Using(var ctx=new HREntities()) { ctx.Database.ExecuteSqlCommand("insert into Employees values {0}, {1}", model.EMPLOYEEID, model.EMPLOYEENAME); ctx.SaveChanges(); } is it possible to execute sql query this way? Thanks. 回答1: You can execute the following types of queries: SQL query for entity types

Entity Framework selection query

邮差的信 提交于 2019-12-04 11:52:58
I am making a simple application for insert, update, delete, select data with Entity Framework I already made insertion, deletion and select all data. Now I want to select with where condition with filter of two fields For ex : I have table with userid username password email Now need selection like where email = "" and password = "" I know how to write query in SQL but having not clues with entity framework . Also need to store this result in datatable and looping solution both for learning purpose. This can help many beginners Beejee Using Linq To Entities with lambda expression: var result

Entity Framework - Updating relationship by changing foreign key

巧了我就是萌 提交于 2019-12-04 11:02:55
问题 I have the two following models and DbContext: public class TestDbContext : DbContext { public IDbSet<Person> People { get; set; } public IDbSet<Car> Cars { get; set; } } public class Person { public Person() { ID = Guid.NewGuid(); } public Guid ID { get; set; } public string Name { get; set; } public virtual List<Car> Cars { get; set; } } public class Car { public Car() { ID = Guid.NewGuid(); } public Guid ID { get; set; } public string Name { get; set; } public virtual Person Owner { get;

Value does not fall within the expected range error

烂漫一生 提交于 2019-12-04 10:16:34
I'm developing an ASP.Net MVC 4 application. I have a module that sends out the invoice in an email (using MVCMailer ) for some reason at I get the error: Value does not fall within the expected range If I step through the code it works without any error but as soon as I just run it it gives me that error. The section producing the error is: return Populate(x => { x.From = new System.Net.Mail.MailAddress("Sales@Scheduler.com", "Scheduler"); x.Subject = System.Configuration.ConfigurationManager.AppSettings["SiteName"].ToString() + " Inovice #" + (invoice.invoiceID + 1000).ToString() + " (" +

UOW and Repository Pattern in EF5

断了今生、忘了曾经 提交于 2019-12-04 09:28:48
This is about some confusion I have about some of the entity framework material I have found from here: https://www.asp.net/ On this Page it explains how to wrap a dbcontext using a repository and to wrap a repository using a a unit of work class: http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application However, on this page it states that a dbcontext is already a combination of both the UOW pattern and the repository pattern: https://msdn.microsoft.com/en-us/library/system.data

Duplicate foreign keys when renaming ASP.NET Identity tables

微笑、不失礼 提交于 2019-12-04 09:15:43
问题 I followed the advice in this question to rename my ASP.NET Identity tables: modelBuilder.Entity<IdentityUserClaim>().ToTable("UserClaim"); modelBuilder.Entity<IdentityUserRole>().ToTable("UserRole"); modelBuilder.Entity<IdentityUserLogin>().ToTable("UserLogin"); modelBuilder.Entity<IdentityRole>().ToTable("Role"); modelBuilder.Entity<IdentityUser>().ToTable("User"); modelBuilder.Entity<ApplicationUser>().ToTable("User"); However this results in two properties for the UserClaim to User

How to upgrade from Entity Framework 4.3 to EF 5

大城市里の小女人 提交于 2019-12-04 09:07:13
问题 Currently we are working on the EF 4.3 . We would like to upgrade it to EF5. I have google the upgrade process steps, but I did not get any result. Please help me..! Thanks.. :) 回答1: Here are two links for you of content I've created on EF4.3 to EF5: article: Moving Existing Projects to EF 5 http://msdn.microsoft.com/en-us/magazine/jj618295.aspx video: Entity Framework 5 Enums and Moving Solution from EF 4.3 http://thedatafarm.com/blog/data-access/video-entity-framework-5-enums-and-moving

Using an SQL View from an Entity Framework Code First version 5

大城市里の小女人 提交于 2019-12-04 08:38:48
问题 I am developing a contact log in a website using VS 2010, MVC3 and EF 5 - the entities are created using code first. The data is stored in an SQL Server 2008 R2 set of databases. I want to display a summary of the contact log and have created a view. CREATE VIEW dbo.ContactLogSummaries AS SELECT CLE.ContactLogEntryID, CLE.CaseID, 'Test' AS ContactName, EU.UserName As OfficeUser, CLE.DateAndTimeOfContact, CLC.Category, CLE.ContactDetails FROM ContactLogEntries AS CLE JOIN ContactLogCategories