entity-framework-6

Active Azure Sql Connections are over the connection pool limit

百般思念 提交于 2019-12-05 17:16:59
问题 We fight the issue in production when once in a while our Azure SQL database performance significantly degrades. We know we have locks on one of the tables, but these locks are not deadlocks, they are long locks and in an hour or so the performance returns to normal. We are trying to find all the possible scenarios on how we get these long locks (every query is super fast and all performance analyzers could show us what causes long locks). The reason for this question is the picture below:

Entity Framework One-Many TPH Mapping

南笙酒味 提交于 2019-12-05 17:05:12
I'm using a data structure similar to this where type of animal is determined from a discriminator column in the table: public class Farm { public int Id { get; set; } public virtual ICollection<Pig> Pigs { get; set; } public virtual ICollection<Cow> Cows { get; set; } } public class Animal { public int Id { get; set; } public int FarmId? { get; set; } public virtual Farm Farm { get; set; } public string Name { get; set; } } public class Pig : Animal {} public class Cow : Animal {} Mapping: this.Map<Pig>(m => m.Requires("Type").HasValue((int) AnimalType.Pig)); this.Map<Cow>(m => m.Requires(

does Visual Studio 2015 include .edmx support?

▼魔方 西西 提交于 2019-12-05 16:43:48
问题 Does Visual Studio 2015 include .edmx support? I have a project that includes an .edmx data model and double-clicking it in VS2015 just opens the XML editor. There's no DbContext generator option in the file->new dialog. 回答1: During setup of VS2015, go to the advanced options and select Web or Database Development tools. Now the Installers install the EF tools (Designer + templates). If you have VS already installed, to the Programs & features in control panel and modify the currently

Calling service/repository methods in ASP.Net Core middleware

ぐ巨炮叔叔 提交于 2019-12-05 16:30:53
ASP.Net Core noob here...I am using an ASP.Net Core WebAPI core project using DNX451 with EF 6. I have a requirement to implement API Key auth in our service. To do this I have created middleware that gets information from the request and proceeds with authentication. It is SUPPOSED to go to the database, get the key to match, and then return and do the validation. Here is the middleware implemented to look at the context and get the APIKey AuthenticationHandler public class AuthorizationHandler { private readonly RequestDelegate _next; private IAuthenticationService _authenticationService;

ASP.NET Entity Framework 6 HashSet or List for a collection?

拟墨画扇 提交于 2019-12-05 16:09:30
问题 My EF models look like this: public class ContentStatus { public ContentStatus() { this.Contents = new List<Content>(); } public int ContentStatusId { get; set; } public string Name { get; set; } public virtual ICollection<Content> Contents { get; set; } } However I have also seen implementatins looking like this: public class ContentStatus { public ContentStatus() { this.Contents = new HashSet<Content>(); } public int ContentStatusId { get; set; } public string Name { get; set; } public

EF 6 filtering child collections

不打扰是莪最后的温柔 提交于 2019-12-05 16:04:06
问题 I'm trying to migrate old project from Linq2Sql to EF6 and I got following issue. This project is multilingual (i.e. all texts have more than 1 translation) and I have following db structure: What is the best way to get all ExampleEntity1 objects with all LocalizedContent records filtered by current language id? I can load all ExampleEntity1 objects with all LocalizedContent records using following code: dc.ExampleEntity1.Include(ee => ee.TextEntry.LocalizedContents); In Linq2Sql I can filter

EntityFramework 6.1.3 does not support framework .NETPlatform,Version=v5.4 on visual studio 2015

你说的曾经没有我的故事 提交于 2019-12-05 15:00:14
问题 Any idea why I receive the following error after Nuget installing Entity framework 6.1.3? Error notice: "The dependency EntityFramework 6.1.3 in project foo bar does not support framework .NETPlatform,Version=v5.4" Here's my global.json (edited out personal data) { "version": "1.0.0-*", "description": foo bar Class Library", "authors": [ "foo bar" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "frameworks": { "net451": { }, "dotnet5.4": { "dependencies": { "Microsoft.CSharp": "4.0.1

Can I use UseCSharpNullComparisonBehavior for a single query?

可紊 提交于 2019-12-05 13:45:17
I have a query that used to be a stored procedure and was converted to an EF query. It is timing out now. Using SQL Profiler, I can see the only difference in the SQL generated is the new behavior where EF turns entity.Property == value into (entity.Property = @value OR (@value IS NULL AND entity.Property IS NULL)) . I know I can turn this off for the entire context by setting UseCSharpNullComparisonBehavior = false , but I really only want to do it for this one query. Is that possible? Or, is there a way to write the EF query so it doesn't generate the SQL like this? You can set the

An exception of type 'System.Data.Entity.Core.EntityException' occurred in EntityFramework.SqlServer.dll but was not handled in user code

时间秒杀一切 提交于 2019-12-05 13:08:16
I am new to ASP.NET MVC, I am facing this exception, the connection string looks perfect but still, the exception is raised, appreciate if anyone give me why is happening. Thank you guys Model 1 namespace MVCTwice.Models { public class StudentContext : DbContext { public DbSet<Student> studs { get; set; } } } Model 2 namespace MVCTwice.Models { [Table("tblStudents")] public class Student { public int id { get; set; } public string name { get; set; } public string gender { get; set; } public string totalMarks { get; set; } } } Action method public ActionResult Index() { StudentContext

How to integrate PostgreSql with EntityFramework 6.0.2?

瘦欲@ 提交于 2019-12-05 12:41:39
I am receiving following error The 'Instance' member of the Entity Framework provider type 'Npgsql.NpgsqlServices, Npgsql, Version=2.0.14.2, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7' did not return an object that inherits from 'System.Data.Entity.Core.Common.DbProviderServices'. Entity Framework providers must inherit from this class and the 'Instance' member must return the singleton instance of the provider. This may be because the provider does not support Entity Framework 6 or later; see http://go.microsoft.com/fwlink/?LinkId=260882 for more information. Can any one help me here is