How can I stop EF Core from creating a filtered index on a nullable column

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);

How do I get the entity that represents the current user in Symfony?

Symfony 4+, 2019+ Approach In symfony 4 (probably 3.3 also, but only real-tested in 4) you can inject the Security service via auto-wiring in the controller like this: <?php use Symfony\Component\Security\Core\Security; class SomeClass { /** * @var Security */ private $security; public function __construct(Security $security) { $this->security = $security; } public function privatePage() : Response … Read more

Self referencing / parent-child relationship in Entity Framework

You must define the ParentId in the category class as nullable to use it as the foreign key property for an optional relationship: public int? ParentId { get; set; } An int property cannot take the value null and therefore cannot represent a NULL as value in a database column.

How can I stop Entity Framework 5 migrations adding dbo. into key names?

You can customize the generated code by sub-classing the CSharpMigrationCodeGenerator class: class MyCodeGenerator : CSharpMigrationCodeGenerator { protected override void Generate( DropIndexOperation dropIndexOperation, IndentedTextWriter writer) { dropIndexOperation.Table = StripDbo(dropIndexOperation.Table); base.Generate(dropIndexOperation, writer); } // TODO: Override other Generate overloads that involve table names private string StripDbo(string table) { if (table.StartsWith(“dbo.”)) { return table.Substring(4); } return table; } … Read more

where is context.Entry()?

may be too late to answer but it may help others, EF 4.0 uses the ObjectContext class where as the version 4.1 uses the DbContext class in which the methods like Set<T> and Entry are defined. With version 4.0 you can do something like DatabaseContext _context = new DatabaseContext(); _context.ObjectStateManager.ChangeObjectState(entity, System.Data.EntityState.Modified); with version 4.1 its … Read more

Entity Framework 1 to 1 relationship using code first. how?

This occurs in CodeFirst because of the virtual keyword. In effect, you are creating a relationship where creating one item requires the creation of the other. however, the virtual keyword allows lazy instantiation, which means that creating an object of one type doesn’t automatically create the other type, allowing the Id on the foreign item … Read more

BeginTransaction with IsolationLevel in EF Core

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)