MySql.Data.EntityFrameworkCore vs Pomelo.EntityFrameworkCore.MySql [closed]
MySql.Data.EntityFrameworkCore vs Pomelo.EntityFrameworkCore.MySql [closed]
MySql.Data.EntityFrameworkCore vs Pomelo.EntityFrameworkCore.MySql [closed]
Shortly, you can’t do that (at least for SqlServer). The explanation is contained in EF Core documentation – Raw SQL Queries – Composing with LINQ: Composing with LINQ requires your raw SQL query to be composable since EF Core will treat the supplied SQL as a subquery. SQL queries that can be composed on begin … Read more
Creating filtered index excluding NULL values is the default EF Core behavior for unique indexes containing nullable columns. You can use HasFilter fluent API to change the filter condition or turn it off by passing null as sql argument: entityBuilder.HasIndex(e => new { e.LevelId, e.Name, e.DeletedAt }) .IsUnique() .HasFilter(null);
@ilya-chumakov’s answer is awesome. I just would like to add one more option 3. Use ConfigureTestServices method from WebHostBuilderExtensions. The method ConfigureTestServices is available in the Microsoft.AspNetCore.TestHost version 2.1(on 20.05.2018 it is RC1-final). And it lets us override existing registrations with mocks. The code: _server = new TestServer(new WebHostBuilder() .UseStartup<Startup>() .ConfigureTestServices(services => { services.AddTransient<IFooService, MockService>(); … Read more
After playing with the code I was able to figure it out. Here is the solution. public async Task DeleteSchoolTask(int schoolNumber, int taskDetailId) { var result = await GetTaskTypeAndId(taskDetailId); int taskId = result.Item1; string taskType = result.Item2; // step 1: delete attachment physically from server var fileService = new FileService(Logger, CurrentUser); var relativeFilePath = $”{schoolNumber}\\{Consts.RM_SCHOOL}\\{taskDetailId}”; … Read more
You have to make changes in .csproj file of your project, need to add InvariantGlobalization attribute to false in PropertyGroup. This is how it looks. <PropertyGroup> <TargetFramework>net8.0</TargetFramework> <ImplicitUsings>enable</ImplicitUsings> <InvariantGlobalization>false</InvariantGlobalization> </PropertyGroup>
All the examples I’ve seen involve either hard-coding the connection string or putting it in my ASP.NET Core application’s settings files. If you aren’t using ASP.NET Core, or maybe, I don’t know, don’t want to have your local environment’s database details committed to source control, you can try using a temporary environment variable. First, implement … Read more
Tools > NuGet Package Manager > Package Manager Settings Clear All NuGet Caches Restart Visual Studio
The EF Core code is exactly the same. DbContext.Database.BeginTransaction(IsolationLevel.Snapshot); The only difference is that in EF Core the method with isolation level (as many others) is an extension method, defined in RelationalDatabaseFacadeExtensions class, and importantly, located in Microsoft.EntityFrameworkCore.Relational assembly. So if you have using Microsoft.EntityFrameworkCore; and don’t see it, add reference to the Microsoft.EntityFrameworkCore.Relational.dll assembly … Read more
UPDATE FOR EF CORE 8 .NET 8 has now built-in support to store lists of primitive types in a column. Read here about Primitive Collections. PRIOR TO EF CORE 8 (or if you want to manually control the serialization instead of using JSON) This can be achieved in a much more simple way starting with … Read more