entity-framework

Should I be using a Generic Repository with Entity Framework 5?

不打扰是莪最后的温柔 提交于 2020-01-22 13:37:12
问题 I'm currently using Entity Framework with a Generic Repository and Unit Of Work Pattern. My Model is similar to the one described in this article I've used Generic Repositories in the past and really enjoyed the global functionality it can provide. However, it seems I'm running into more problems every single day when it comes to using it with Entity Framework. These problems seem to arise even more when it comes to handling Parent/Children/Junction relationships. Using a Generic Repository

Should I be using a Generic Repository with Entity Framework 5?

孤街浪徒 提交于 2020-01-22 13:36:05
问题 I'm currently using Entity Framework with a Generic Repository and Unit Of Work Pattern. My Model is similar to the one described in this article I've used Generic Repositories in the past and really enjoyed the global functionality it can provide. However, it seems I'm running into more problems every single day when it comes to using it with Entity Framework. These problems seem to arise even more when it comes to handling Parent/Children/Junction relationships. Using a Generic Repository

Entity Framework upgrade to 6.2.0 from 6.1.x breaks certain queries unless I enable MARS

杀马特。学长 韩版系。学妹 提交于 2020-01-22 13:26:31
问题 I recently upgraded EF 6.1.3 to 6.2.0 on one of our large projects, and it has broken a significant amount of our LINQ queries. Enabling MultipleActiveResultSets causes everything to work as normal again, but I'm struggling to understand the change. We have been using EF for years and gone through multiple major version changes without any issue. If I simply revert back to 6.1.3, everything works again as expected - in fact everything works even if I explicitly disable MARS in 6.1.3 . Let me

Unable to setup MiniProfiler w/ Enity Framework 4.0 (Not code first)

北城以北 提交于 2020-01-22 13:05:23
问题 I installed MiniProfiler and MiniProfiler.EF in my project via nuget. Before using MiniProfiler I would open a connection using this in my model repository: public class NotificationRepository { private CBNotificationModel.CB_NotificationEntities db; public NotificationRepository() { db = new CB_NotificationEntities(); } public NotificationContact GetNotificationContacts() { return db.NotificationContacts.ToList(); } } To use mini profiler I created: public static class ConnectionHelper {

Unable to setup MiniProfiler w/ Enity Framework 4.0 (Not code first)

若如初见. 提交于 2020-01-22 13:02:26
问题 I installed MiniProfiler and MiniProfiler.EF in my project via nuget. Before using MiniProfiler I would open a connection using this in my model repository: public class NotificationRepository { private CBNotificationModel.CB_NotificationEntities db; public NotificationRepository() { db = new CB_NotificationEntities(); } public NotificationContact GetNotificationContacts() { return db.NotificationContacts.ToList(); } } To use mini profiler I created: public static class ConnectionHelper {

Stored procedures EF and NET CORE

不羁的心 提交于 2020-01-22 12:57:32
问题 I am building a WEB API to generate JSON objects in .net core The thing is the data sets are generated in SQL stored procedures (using dynamic SQL) and i dont know the type of objects that are returned so i can map it to a concrete model, since the output columns change depending on the parameters. Does any one know ho to retrive the data set from the BD in net core 1.0 with or without using EF? Browsed a lot and can only find ansers that use models Thanks in advance 回答1: You can add the

Entity Framework 4 with Existing Domain Model

天大地大妈咪最大 提交于 2020-01-22 12:56:40
问题 Im currently looking at migrating from fluent nHibernate to ADO.Net Entity Framework 4. I have a project containing the domain model (pocos) which I was using for nHibernate mappings. Ive read in blogs that it is possible to use my existing domain model with EF4 but ive seen no examples of it. Ive seen examples of T4 code generation with EF4 but havent come accross an example which shows how to use existing domain model objects with EF4. Im a newby with EF4 and would like to see some samples

One-to-One relationships in Entity Framework 7 Code First

▼魔方 西西 提交于 2020-01-22 12:03:28
问题 How to configure One-to-One or ZeroOrOne-to-One relationships in Entity Framework 7 Code First using Data Annotations or Fluent Api? 回答1: You can define OneToOne relationship using Fluent API in Entity Framework 7 as below class MyContext : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<BlogImage> BlogImages { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Blog>() .HasOne(p => p.BlogImage) .WithOne(i => i.Blog)

One-to-One relationships in Entity Framework 7 Code First

狂风中的少年 提交于 2020-01-22 12:02:44
问题 How to configure One-to-One or ZeroOrOne-to-One relationships in Entity Framework 7 Code First using Data Annotations or Fluent Api? 回答1: You can define OneToOne relationship using Fluent API in Entity Framework 7 as below class MyContext : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<BlogImage> BlogImages { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Blog>() .HasOne(p => p.BlogImage) .WithOne(i => i.Blog)

One-to-One relationships in Entity Framework 7 Code First

旧巷老猫 提交于 2020-01-22 12:02:28
问题 How to configure One-to-One or ZeroOrOne-to-One relationships in Entity Framework 7 Code First using Data Annotations or Fluent Api? 回答1: You can define OneToOne relationship using Fluent API in Entity Framework 7 as below class MyContext : DbContext { public DbSet<Blog> Blogs { get; set; } public DbSet<BlogImage> BlogImages { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Blog>() .HasOne(p => p.BlogImage) .WithOne(i => i.Blog)