Home > OS >  ASP.NET MVC & Entity Framework : keyword not supported:
ASP.NET MVC & Entity Framework : keyword not supported:

Time:04-03

I can't create my Entity Framework word database in the ASP.NET MVC project; I get an error

Keyword not supported: 'database'

even if I change my database name.

How can I fix it?

It's weird because I can migrate the database but this error pops up when I try to update it

My DbContext

public class SpletneContext : DbContext
{
    public DbSet<UporabnikM> Uporabniki { get; set; }
    public DbSet<Glasba> Glasbe { get; set; }
    public DbSet<Instrument> Instrumanti { get; set; }
    public DbSet<Oseba> Oseba { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlServer(
            @"Server=(localdb)\mssqllocaldb;DinamicneSpletne=C;Trusted_Connection=True");
    }
}

enter image description here

CodePudding user response:

It seems that your connection string is incorrect, it should look like this:

"Data Source=(localdb)\mssqllocaldb;Initial Catalog=YOUR_DATABASE_NAME;Trusted_Connection=True;

CodePudding user response:

Looks like your connection string not correct format. Might it because of "\" this.

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {

        optionsBuilder.UseSqlServer(
        @"Server=(localdb)mssqllocaldb;DinamicneSpletne=C;Trusted_Connection=True");
    }
  • Related