0

I have got .Net Standart 2.0 dll to keep separated entities of MS SQL Server.

The Index Attribute cannot be resolving.

I've did search and experimented with adding some namespaces of Entity Framework but nothing works even by MSDN.

Please, help. Thank you!

enter image description here

enter image description here

1
  • 1
    learn.microsoft.com/en-us/ef/core/modeling/… - see the note: "Configuring indexes via Data Annotations has been introduced in EF Core 5.0." (and you have EF Core 3.1.19) Commented Sep 29, 2021 at 8:56

1 Answer 1

1

IndexAttribute Class

Specifies an index to be generated in the database.

Entity Framework Core

  • 5.0

You are not using EF core 5. You will need to use the model Builder instead


Read more here

Indexes

Configuring indexes via Data Annotations has been introduced in EF Core 5.0.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Blog>()
        .HasIndex(b => b.Url);
}
Sign up to request clarification or add additional context in comments.

7 Comments

I've restored database model via Scaffold-DbContext so what is the correct solution to do it properly to get the model Builder syntax? I don't like to manualy change the code evrey time I've update the model...
@DmitryBoyko this is part of your DBContext learn.microsoft.com/en-us/ef/core/modeling
@DmitryBoyko you could upgrade to core 5 :) honestly I don't know the answer that particular question of how to persist modal builder changes on when updating form a db
It is unclear what is the solution you offer... Would you mind to detail it in your answer please? Thank you!
Error NU1202 Package Microsoft.EntityFrameworkCore 5.0.10 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Package Microsoft.EntityFrameworkCore 5.0.10 supports: netstandard2.1 (.NETStandard,Version=v2.1)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.