efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Exception on upgrade [Bug]

Open GVX111 opened this issue 11 years ago • 4 comments

Exception on: Database.Migrate();

An exception of type 'System.ArgumentException' occurred in EntityFramework.Core.dll but was not handled in user code
Additional information: The properties expression 'u => Convert(Convert(u).Id)' is not valid. The expression should represent a property access: 't => t.MyProperty'. When specifying multiple properties use an anonymous type: 't => new { t.MyProperty1, t.MyProperty2 }'.

GVX111 avatar Sep 29 '15 11:09 GVX111

I guess the exception occurred because you entered wrong syntax. can you put your code?

NeelBhatt avatar Sep 29 '15 11:09 NeelBhatt

Its worked correctly before dnu restore

 public class Account : IdentityUser
    {
        public string Firstname { get; set; }
        public string Lastname { get; set; }
        public DateTime Birthdate { get; set; }
        public bool Gender { get; set; }

```
    public string GetGender()
    {
        return Gender ? "Male" : "Female";
    }
}
public class EfContext : IdentityDbContext
{
    private static bool _created = false;
    public DbSet Accounts { get; set; }
    public DbSet Sites { get; set; }
    public DbSet Pages { get; set; }

    public EfContext()
    {
        // Create the database and schema if it doesn't exist
        // This is a temporary workaround to create database until Entity Framework database migrations 
        // are supported in ASP.NET 5 
        if (!_created)
        {
            Database.Migrate();
            // this.Configuration.ProxyCreationEnabled = false;
            _created = true;
        }
    }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlServer("Server=***;Database=***; User Id=**; Password=*****; MultipleActiveResultSets=true");
    }

}
```
                                    

GVX111 avatar Sep 29 '15 11:09 GVX111

possible dupe of #3267

smitpatel avatar Sep 29 '15 22:09 smitpatel

Fixed now (see #3267)

rowanmiller avatar Oct 02 '15 18:10 rowanmiller