entity-framework-core

Suppress EF core 3.0.x initialized msg

给你一囗甜甜゛ 提交于 2019-12-11 12:25:18
问题 I have: protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { string connectionString = "mydb.db;"; optionsBuilder .UseLoggerFactory(MainWorker.ConsoleLoggerFactory) .EnableSensitiveDataLogging(true) .UseSqlite(connectionString); } Whenever I access my DBContext the console shows info: Microsoft.EntityFrameworkCore.Infrastructure[10403] Entity Framework Core 3.0.0-preview4.19176.6 initialized Is there a way to filter out this particular message ? as I do a lot of

Entity Framework Core sends a request to Microsoft addresses when accessing the library

只愿长相守 提交于 2019-12-11 10:55:27
问题 My program ( C# , WinForms , Visual Studio ) uses Entity Framework Core to work with Office Access . The database provider is Jet. The context generated by the command Scaffold DbContext . When, during the operation of the program call the command context Add() , Update() , Remove() , SaveChanges() - program is the outgoing request (catches firewall antivirus). Request to the address 52.109.*.* . For example, 52.109.124.23 . According to Whois, the address belongs to Microsoft . Such activity

DbContext cannot find database

一曲冷凌霜 提交于 2019-12-11 10:42:05
问题 The connection string for our app is set in appsettings.json "Data": { "DefaultConnection": { "ConnectionString": "Server=(localdb)\\mssqllocaldb;Database=Customers;Trusted_Connection=True;MultipleActiveResultSets=true", In ConfigureServices we have services.AddEntityFramework() .AddSqlServer() .AddDbContext<CustomersContext>(options => options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"])); This seems to work in cases like this var membershipUser = await _userManager

Empty Login Name When Showing sys.processes

﹥>﹥吖頭↗ 提交于 2019-12-11 10:37:05
问题 As per the issue here: SQL Query continues running for a very long time if search term not found I faced an issue that my Azure website hits 100% DTU very fast as soon as I publish the search feature to the public. After further investigation, I ran the following query to show all processes on my database: SELECT DB_NAME(dbid) as DBName, COUNT(dbid) as NumberOfConnections, loginame as LoginName FROM sys.sysprocesses WHERE dbid > 0 GROUP BY dbid, loginame The weird thing is that in addition to

In an ASP.Net vNext site, why does a migrations-related exception appear at startup?

浪子不回头ぞ 提交于 2019-12-11 10:36:39
问题 I have no migrations defined but I am still seeing an exception about the __MigrationHistory table at startup, after a lengthy timeout. My initialization code looks like this: public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddEntityFramework() .AddSqlServer() .AddDbContext<DiContext>(options => options.UseSqlServer(Configuration.Get("ConnectionString"))); } public void Configure(IApplicationBuilder app) { var loggerFactory = (ILoggerFactory)app

EF7 Incorrect configuration of the DBContext?

谁说我不能喝 提交于 2019-12-11 10:19:28
问题 I am trying to figure out if my DBContext is set right. The Web Application I am trying to do is using ASP.NET 5, MVC6 and EF7. It is connected to a DB that contains 3 tables (Comment, Review, Film). This is my model WebDbModel.cs using Microsoft.AspNet.Identity.EntityFramework; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; namespace WebExample.Models { public partial class Comment : IdentityUser { public string CommentId { get; set; } public

EF.Functions.Contains including multiple keywords

一个人想着一个人 提交于 2019-12-11 10:03:01
问题 I need to search on multiple columns (LearningModuleDesc and LearningModuleContent which works using the || statements below) but I also need to search on multiple keywords. .Net Core 2.2 and EF Core does not support the string array with Contains (like the example below) but some guidance of how I would go about this would be great. string[] stringarray = new string[] { "mill", "smith" }; var results = _context.LearningModules .Where(x => EF.Functions.Contains(x.LearningModuleDesc,

Can I make Entity Framework use sqlite's LIKE instead of instr()?

谁都会走 提交于 2019-12-11 09:45:56
问题 Currently using .NET Core 2. I use a LINQ query similar to: var peopleInRoseStreet = context.Person .Include(p => p.Addresses) .Where(p => p.Addresses.Any(a => a.Text.Contains("rose"))); EF seems to translate this to: SELECT "p".* FROM "Person" AS "p" WHERE EXISTS ( SELECT 1 FROM "PersonAddress" AS "a" WHERE (instr("a"."Text", 'rose') > 0) AND ("p"."Id" = "a"."person_id")) ORDER BY "p"."Id" By using instr() , the comparison is case-sensitive although the PersonAddress.Text column is set to

Updating related Phone entities with custom tag helper

好久不见. 提交于 2019-12-11 09:29:12
问题 As my application currently sits, each AppUser may (or may not) have 3 phone numbers ( UserPhones ). One of each type (Mobile, Home, Other). The following Tag Helper works great (Thanks @itminus). Calling code from Razor Page: <user-phones phones="@Model.UserPhones" asp-for="@Model.UserPhones" prop-name-to-edit="PhoneNumber" types-to-edit="new EnumPhoneType[] { EnumPhoneType.Mobile, EnumPhoneType.Other }" /> Code: public class UserPhonesTagHelper : TagHelper { private readonly IHtmlGenerator

EFCore Update using UnitOfWork Repository and Service with AutoMapper

五迷三道 提交于 2019-12-11 08:54:53
问题 Following the N-tier architecture, I'm currently having issues while trying to update an entity. In my Controller, if I set the properties manually, the update works perfectly, if I set the properties mapping the ViewModel into the entity it generate the exception "...cannot track multiple objects with the same key". How can I solve this? This is my UnitOfWork: public class UnitOfWork : IUnitOfWork { private readonly CoreContext _context; private IGenericRepository<Currency>