Quantcast
Channel: Entity Framework
Viewing all 10318 articles
Browse latest View live

Commented Issue: [Performance] Amount of associations in model affects materialization times [1829]

$
0
0
Analyzing bug [1781](https://entityframework.codeplex.com/workitem/1781) it became apparent that a basic performance limitation of EF requires additional investigation. The time it takes EF to materialize data is a function of the amount of associations (foreign keys) the entire model has, even when such associations are not part of the query in question.

As an example, using the AdventureWorks database generate an EDMX model, then have the following query:
```
List<SalesOrderHeader> headers = null;
using (var ctx = new AdventureWorksEntities())
{
headers = ctx.SalesOrderHeader.ToList();
}
```
This will materialize 31465 SalesOrderHeader entities. But the time it takes to do so depends on the size of the model we have. The test machine used has Windows 8.1 64-bit, .NET 4.5.1, high performance power setting, 12 GB RAM, Intel Xeon W3530 CPU at 2.8 GHz.

If the EDMX only has one entity type (SalesOrderHeader) materialization takes 840 milliseconds (median value, 10 runs), but when the EDMX contains a richer model, for example one with 67 entity types and 92 associations, the same test takes 7246 milliseconds to complete (median value, 10 runs).

The additional CPU is spent on code that’s affected by the amount of foreign keys in the model. The biggest difference seems to come from EntityEntry.TakeSnapshot() as it’s massively affected. It went from 173 samples to 29547 samples due to the cost of the call to TakeSnapshotOfForeignKeys(), according to Visual Studio 2013 sampling profiles.

The second biggest difference comes from ObjectStateManager.FixupReferencesByForeignKeys() which went from 5 samples to 20172 samples.

This requires additional investigation.
Comments: Hi Sebastien, Could you create a new workitem and include a repro? What you are describing seems completely unrelated to #1829, plus we would like to understand what is making your models so slow and also if you are following the necessary steps to cache the model correctly for each separate database schema. Thanks, Diego

New Post: Issue 1043-Efficient API to ask if there are pending changes on a DbContext

$
0
0
Even though HasChanges is fast, we are calling it to determine if buttons on the UI should be enabled or not in WPF CanExecute relay command. What is wrong with a HasChangesChanging event? (or whatever you might want to call it).

R

Commented Issue: Resource Contention Limiting Parallelism [636]

$
0
0
It seems that, when multiple instances of DbContext exist on multiple threads and each thread calls SaveChanges(), there is some form of resource contention in EF itself limiting throughput.

VS2012's profiler says there is 61% contention for a resource called Handle 2 in a specific run of a specific use case.

Details are outlined on Stack Overflow:

http://stackoverflow.com/q/13182603/141172
Comments: Hi, I was having the same problem and this worked for me: http://social.msdn.microsoft.com/Forums/en-US/af589b9e-9794-49ca-abbc-efca2a5f19b3/c-thread-contention-with-sqldatareaders-and-sqldataadapters?forum=adodotnetdataproviders

Commented Issue: [Performance] Amount of associations in model affects materialization times [1829]

$
0
0
Analyzing bug [1781](https://entityframework.codeplex.com/workitem/1781) it became apparent that a basic performance limitation of EF requires additional investigation. The time it takes EF to materialize data is a function of the amount of associations (foreign keys) the entire model has, even when such associations are not part of the query in question.

As an example, using the AdventureWorks database generate an EDMX model, then have the following query:
```
List<SalesOrderHeader> headers = null;
using (var ctx = new AdventureWorksEntities())
{
headers = ctx.SalesOrderHeader.ToList();
}
```
This will materialize 31465 SalesOrderHeader entities. But the time it takes to do so depends on the size of the model we have. The test machine used has Windows 8.1 64-bit, .NET 4.5.1, high performance power setting, 12 GB RAM, Intel Xeon W3530 CPU at 2.8 GHz.

If the EDMX only has one entity type (SalesOrderHeader) materialization takes 840 milliseconds (median value, 10 runs), but when the EDMX contains a richer model, for example one with 67 entity types and 92 associations, the same test takes 7246 milliseconds to complete (median value, 10 runs).

The additional CPU is spent on code that’s affected by the amount of foreign keys in the model. The biggest difference seems to come from EntityEntry.TakeSnapshot() as it’s massively affected. It went from 173 samples to 29547 samples due to the cost of the call to TakeSnapshotOfForeignKeys(), according to Visual Studio 2013 sampling profiles.

The second biggest difference comes from ObjectStateManager.FixupReferencesByForeignKeys() which went from 5 samples to 20172 samples.

This requires additional investigation.
Comments: Hi Sebastien, I second Diego: we'd like to hear more from you. If you could create a bug describing the models you are using, or better yet, attaching a repro of the bug for our analysis, that would be very helpful. Additionally, you can generate the EDMX from the code first project. ```C# EdmxWriter.WriteEdmx(context, new XmlTextWriter(new StreamWriter("MyModel.edmx")));``` Call it in your context instance and you’ll get an EDMX file with all the data you require. Add the EDMX to your project and [modify your connection string](http://msdn.microsoft.com/en-us/library/vstudio/cc716756(v=vs.110).aspx) accordingly to make use of the EDMX data. David.

New Post: Multi-Tenant With Code First

$
0
0
This was a nice approach. I tried it and it is the cleanest one I saw till now. Anyway, there is a problem if you want to use the same aproach on the identity context (ApplicationDbContext).

I tried that also, but am getting all the time the orignal schema which is the table names without schema. I think there is some other magic going on behind the scene there. If any know what it is, I appreciate a tips...will look deeper at it myself also. Here is is the code I am testing with
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {       
        internal ApplicationDbContext(string tenantName, string connectionString)
            : base(connectionString)
        {
             Configuration.LazyLoadingEnabled = false;
             System.Data.Entity.Database.SetInitializer<ApplicationDbContext>(null);
              this.TenantName = tenantName;
        }

        public static ApplicationDbContext Create(string tenantName, string connectionString)
        {
            return new ApplicationDbContext(tenantName, connectionString);
        }
         public string CacheKey
        {
            get { return this.TenantName; }
        }

        private string TenantName { get; set; }

        protected override void OnModelCreating(System.Data.Entity.DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
          
            if (TenantName != null)
            {
                // modelBuilder.HasDefaultSchema(this.TenantName); Tried this first, but did not helpt neither
                modelBuilder.Entity<IdentityUser>().ToTable(TenantName + "_AspNetUsers");
                modelBuilder.Entity<ApplicationUser>().ToTable(TenantName + "_AspNetUsers");
                modelBuilder.Entity<IdentityUserClaim>().ToTable(TenantName + "_AspNetUserClaims");
                modelBuilder.Entity<IdentityUserLogin>().ToTable(TenantName + "_AspNetUserLogins").HasKey<string>(l => l.UserId);
                modelBuilder.Entity<IdentityRole>().ToTable(TenantName + "_AspNetRoles").HasKey<string>(r => r.Id);
                modelBuilder.Entity<IdentityUserRole>().ToTable(TenantName + "_AspNetUserRoles").HasKey(r => new { r.RoleId, r.UserId });
            }            
        }
    }

New Post: Defining entities at runtime - AddEntitySetBase is internal

$
0
0
For the current project I am working on, I require the ability to define entities at runtime (within IConceptualModelConvention and IStoreModelConvention implementations).

It seems like I am able to define the entire metadata model required however I am unable to add the created EntitySet to the EntityContainer, this is because EntityContainer.AddEntitySetBase is marked as internal. Is there a compelling reason for this? Especially considering EntityContainer.RemoveEntitySetBase is marked as public.

Thanks,

Luke

New Post: Defining entities at runtime - AddEntitySetBase is internal

$
0
0
Currently I'm using reflection to invoke the method like so:
private static Action<EntityContainer, EntitySetBase> BuildAddEntitySetBaseDelegate()
{
    var entityContainerType = typeof (EntityContainer);
    var entityContainer = Expression.Parameter(entityContainerType);
    var entitySetBase = Expression.Parameter(typeof (EntitySetBase));

    var addEntitySetBaseMethod = entityContainerType.GetTypeInfo().GetMethod("AddEntitySetBase", BindingFlags.Instance  | BindingFlags.NonPublic);
    var methodInvocation = Expression.Call(entityContainer, addEntitySetBaseMethod, new Expression[] {entitySetBase});

    var lambda = Expression.Lambda<Action<EntityContainer, EntitySetBase>>(methodInvocation, entityContainer, entitySetBase);
    return lambda.Compile();
}
I haven't had any issues with this so far.

New Post: Extend MetadataWorkspace EntityType

$
0
0
Hi,

Is there any way to extend this metadata class with aditional information such as custom data annotations, index data, etc? If not, how can i cache this metadata per db type?

Thanks a lot

Edited Unassigned: Issue with navigation properties & entity splitting [2465]

$
0
0
Starting with Entity Framework 6.1.1, an argument exception is raised for navigation properties when using entity splitting. Interestingly, this only occurs when more than 2 tables are mapped to one entity.

```
public class Customer
{
public int CompanyNumber { get; set; }

public bool Active { get; set; }

public int PaymentTermsNumber { get; set; }

public string LabelNotes { get; set; }

public int FreightTermsNumber { get; set; }

public virtual PaymentTerms PaymentTerms { get; set; }

public virtual FreightTerms FreightTerms { get; set; }


public class EntityTypeConfiguration : EntityTypeConfiguration<Customer>
{
public EntityTypeConfiguration()
{
Property(p => p.CompanyNumber).HasColumnName("COMPANY_NO");

HasKey(k => k.CompanyNumber);

Map(m =>
{
m.Property(p => p.Active).HasColumnName("ACTIVE_FL");
m.ToTable("F_CUSTOMER", "GLOBAL");
});

// No exception will be raised for the first or second table referenced (i.e. FreightTerms)
Map(m =>
{
m.Property(p => p.LabelNotes).HasColumnName("LABEL_NOTES");
m.Property(p => p.FreightTermsNumber).HasColumnName("FREIGHT_TERM_NO");
m.ToTable("F_CUSTOMER_PREFS", "GLOBAL");
});

// System.ArgumentException: The item with identity 'Customer_PaymentTerms1' already exists in the metadata collection.
Map(m =>
{
m.Property(p => p.PaymentTermsNumber).HasColumnName("PAYMENT_TERM_NO");
m.ToTable("F_CUSTOMER_CREDIT", "GLOBAL");
});

HasRequired(p => p.FreightTerms).WithMany().HasForeignKey(p => p.FreightTermsNumber);
HasRequired(p => p.PaymentTerms).WithMany().HasForeignKey(p => p.PaymentTermsNumber);
}
}
}
```

```
System.ArgumentException was unhandled
HResult=-2147024809
Message=The item with identity 'Customer_PaymentTerms1' already exists in the metadata collection.
Parameter name: item
Source=EntityFramework
ParamName=item
StackTrace:
at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.AddInternal(T item)
at System.Data.Entity.Core.Metadata.Edm.MetadataCollection`1.Add(T item)
at System.Data.Entity.Core.Metadata.Edm.EntitySetBaseCollection.Add(EntitySetBase item)
at System.Data.Entity.Core.Metadata.Edm.EntityContainer.AddEntitySetBase(EntitySetBase entitySetBase)
at System.Data.Entity.ModelConfiguration.Edm.EdmModelExtensions.AddAssociationSet(EdmModel model, AssociationSet associationSet)
at System.Data.Entity.Core.Metadata.Edm.ForeignKeyBuilder.SetOwner(EntityType owner)
at System.Data.Entity.Core.Metadata.Edm.EntityType.AddForeignKey(ForeignKeyBuilder foreignKeyBuilder)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.ForeignKeyPrimitiveOperations.CopyForeignKeyConstraint(EdmModel database, EntityType toTable, ForeignKeyBuilder fk, Func`2 selector)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.ForeignKeyPrimitiveOperations.<>c__DisplayClass39.<CopyAllForeignKeyConstraintsForColumn>b__37(ForeignKeyBuilder fk)
at System.Data.Entity.Utilities.IEnumerableExtensions.Each[T](IEnumerable`1 ts, Action`1 action)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.ForeignKeyPrimitiveOperations.CopyAllForeignKeyConstraintsForColumn(EdmModel database, EntityType fromTable, EntityType toTable, EdmProperty column, EdmProperty movedColumn)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.TableOperations.CopyColumnAndAnyConstraints(EdmModel database, EntityType fromTable, EntityType toTable, EdmProperty column, Func`2 isCompatible, Boolean useExisting)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingOperations.UpdatePropertyMapping(EdmModel database, Dictionary`2 columnMappingIndex, ColumnMappingBuilder propertyMappingBuilder, EntityType fromTable, EntityType toTable, Boolean useExisting)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingOperations.MovePropertyMapping(DbDatabaseMapping databaseMapping, MappingFragment fromFragment, MappingFragment toFragment, ColumnMappingBuilder propertyMappingBuilder, Boolean requiresUpdate, Boolean useExisting)
at System.Data.Entity.ModelConfiguration.Configuration.Mapping.EntityMappingConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest, EntityType entityType, EntityTypeMapping& entityTypeMapping, Boolean isMappingAnyInheritedProperty, Int32 configurationIndex, Int32 configurationCount, IDictionary`2 commonAnnotations)
at System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration.ConfigureTablesAndConditions(EntityTypeMapping entityTypeMapping, DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.ConfigureEntityTypes(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.ModelConfiguration.Configuration.ModelConfiguration.Configure(DbDatabaseMapping databaseMapping, DbProviderManifest providerManifest)
at System.Data.Entity.DbModelBuilder.Build(DbProviderManifest providerManifest, DbProviderInfo providerInfo)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
at System.Data.Entity.Internal.Linq.InternalSet`1.Find(Object[] keyValues)
at System.Data.Entity.DbSet`1.Find(Object[] keyValues)
at IsolateCustomerEFIssue.Form1.timer1_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at IsolateCustomerEFIssue.Program.Main()
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
```

Edited Feature: Need a public method in DbModelBuilder [2447]

$
0
0
need a public method in DbModelBuilder

public virtual EntityTypeConfiguration Entity(Type type) {};

so we can use like this

foreach (var entityType in entityTypeList)
{
dbmodelBuilder.Entity(type);
}

Although we can use EntityTypeConfiguration and Flunet api to generate DbContext, we want to use entity
class to generate DbContext becouse of OO conception.

Created Unassigned: nullreferenceexception entity framework when table is null [2467]

$
0
0
hi all
im using entity framework 6.1.1 and code first And Use UnitOfWork

this is my unitofwork interface:

```
public interface IUnitOfWork
{

IDbSet<TEntity> Set<TEntity>() where TEntity : class;
}

```

this is my datacontext

```
public partial class myDataContext : DbContext, IDbContext
{
public new IDbSet<TEntity> Set<TEntity>() where TEntity : class
{
return base.Set<TEntity>();
}

1- public DbSet<ProductInventory> ProductInventories { get; set; }
2- public DbSet<ProductUnitDefain> ProductUnitDefains { get; set; }


}

```
this is Service Layer :

public readonly IDbSet<ProductUnitDefain> Entity;

im loading data with observablecollection and local metod for each model

```
public ObservableCollection<ProductUnitDefain> GetProductUnitDefainList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductUnitDefain>(Entity.Local);

}

public ObservableCollection<ProductInventory> GetProductInventoryList(int product)
{
Entity.Where(x => product != null && x.Product == product).Load();
return new ObservableCollection<ProductInventory>(Entity.Local);

}
```
i have 2 table in context:
ProductUnitDefain
and
ProductInventory

but exception error for ProductUnitDefain only
and ProductInventory worked perfectly

if table ProductUnitDefain is null
when Add Or Update record in to ProductUnitDefain exception nullreferenceexception in line:
return new ObservableCollection<ProductUnitDefain>(Entity.Local);
if ProductUnitDefain table have any record worked perfectly and no exception
how to resolve this problem
thanks




Commented Feature: Code First: Allow indexes to be specified using attribute/fluent API [57]

$
0
0
"Problem Description:
I'm looking forward to [StoreIgnore] attribute in EF 4 CTP 5. I would like to see a way to create index in table. Something like: [Indexed(Unique=false,Clustered=false)] int A { get; set; } [Indexed(Unique=false,Clustered=false)] int B { get; set; } [Indexed(Unique=false,Clustered=false)] int C { get; set; }"

This item was migrated from the DevDiv work item tracking system [ID=87553].

This work item originated from connect.microsoft.com. A member of the EF team at Microsoft should close the related Connect issue when closing this work item.

Comments: It would be nice if when addressing 1966 and/or 1969, you would also address the problem that IndexAttribute IsUnique is essentially useless for nullable columns. Often people want a column where the value can either be null, or not null - and if not null, you want it to be unique. This is accomplished in SQL Server 2008 and later using filtered indexes (http://msdn.microsoft.com/en-us/library/cc280372.aspx). It would be great if you could extend the IndexAttribute and/or fluent API functionality to support filtered indexes to address this shortcoming. It would be somewhat DB specific, in that MSSQL < 2008 doesn't support it, and mysql and postgres I think ignore null by default so it isn't needed but supporting less than 2008 for all features probably isn't practical anyway? I'd be willing to make a stab at this, but it strikes me that the easy way wouldn't necessarily be elegant but I'm not sure making it elegant is worth the trouble. Today the code is writer.Write("CREATE "); if (createIndexOperation.IsUnique) { writer.Write("UNIQUE "); } if (createIndexOperation.IsClustered) { writer.Write("CLUSTERED "); } writer.Write("INDEX "); writer.Write(Quote(createIndexOperation.Name)); writer.Write(" ON "); writer.Write(Name(createIndexOperation.Table)); writer.Write("("); writer.Write(createIndexOperation.Columns.Join(Quote)); writer.Write(")"); you could just add another optional parameter to the attribute and tack the following on to the above code: if (!string.IsNullOrWhitespace(createIndexOperation.Filter) writer.Write(createIndexOperation.Filter); For this case where you want to ignore NULL values, the Filter string would be something like "WHERE Column IS NOT NULL".

Commented Unassigned: MigrationsHistory ContextKey is broken after running UpdateDatabase [2461]

$
0
0
In my application it is required not to migrate the database on runtime. In my architecture code that deals with Entity Framework is encapsulated into a separated dll, which is consumed by the application, some unit tests and a Console Application. The application and the unit tests connects to different databases.

The Console application is present for migrating stuff: Everytime the model changes, the console application is run to migrate the target database (which can be either the applications or test database). I found a solution to run Enable-Migrations on a context that is defined in a dll instead of the target project here:

[Migrations: Allow context and migrations to be in separate projects](http://www.example.com)

When I add a migration, run Update-Database the context key in the MigrationsHistory contains the wrong Type name, and Entity Framework could not find migration informationen for the data context. In fact, the MigrationsHistory contains the typename of the Migrations Configuration class as Context key, but as far as I understood the Context key should refer the typename of the context (which is referenced in another dll in my case).

When using the context from the application or from a test, I got the following exception:

System.NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations.

The command I run were the following:

1.) Enable-Migrations -ProjectName "SmartDoc.DatabaseMigrator" -ContextProjectName "SmartDoc.Persistence.EntityFramework" -ConnectionString "Data Source=.;Initial Catalog=SmartDocDatabase;Integrated Security=SSPI;" -ConnectionProviderName "System.Data.SqlClient"

2.) Add-Migration "Migration1" -ProjectName "SmartDoc.DatabaseMigrator"
3.) Update-Database –Verbose -ProjectName "SmartDoc.DatabaseMigrator" -ConnectionString "Data Source=.;Initial Catalog=SmartDocTestDatabase;Integrated Security=SSPI;" -ConnectionProviderName "System.Data.SqlClient"


I tried to debug the update-database command but I found no solution to debug the powershell modules. Could you please help me to find a solution on that issue?

Thanks a lot,
Sebastian.



Comments: Hey Sebastian, We may be misunderstanding this, but could you just set the ContextKey property in the migrations configuration to match what is in the table? I think the issue is that your tests etc. don't know that the migrations configuration exists (since they are in a different assembly), so they are assuming the context name would be the key rather than the configuration name (which we use instead once migrations are enabled). If you set the ContextKey to the context name then it should al work. ~Rowan

Created Issue: Update EntityDesignPackage.csproj to use MSBuildExtensionsPath32 [2472]

$
0
0
In src/EFTools/EntityDesignPackage/EntityDesignPackage.csproj, we should be using `$(MSBuildExtensionsPath32)` instead of `$(ProgramFiles)\MSBuild`. `$(ProgramFiles)` is different depending on whether the process is 32-bit or 64-bit.

Closed Unassigned: Default constraint not imported by EF 6 [2460]

$
0
0
I am generating database model for an existing database; the model was generated without errors. However, none of the default constraints were imported into the model.

Also, If I add the constraints to the model then edmx file generated doesn't show the default constraint.

Please suggest
Comments: __EF Team Triage:__ EF currently doesn't have the concept of default constraints in the model. The default value that you see in the designer is just a value that is set for the property when new instances of the class are created (you'll see the code to do this is generated in the constructor of the entity class). We do have an existing work item to track better support for default constraints/values - https://entityframework.codeplex.com/workitem/44.

Edited Feature: UpForGrabs: Allow index to use desc order on column [2456]

$
0
0
Would be nice if we could create indexes with desc order columns like:

```
ALTER TABLE dbo.Employees ADD CONSTRAINT
IX_Employees_EmplyeeCardNumber UNIQUE CLUSTERED
(
EmployeeCardNumber DESC
)
```

See stackoverflow question: [How to create index in desc order in code first?](http://stackoverflow.com/questions/25004125/how-to-create-index-in-desc-order-in-code-first)

Commented Feature: UpForGrabs: Allow index to use desc order on column [2456]

$
0
0
Would be nice if we could create indexes with desc order columns like:

```
ALTER TABLE dbo.Employees ADD CONSTRAINT
IX_Employees_EmplyeeCardNumber UNIQUE CLUSTERED
(
EmployeeCardNumber DESC
)
```

See stackoverflow question: [How to create index in desc order in code first?](http://stackoverflow.com/questions/25004125/how-to-create-index-in-desc-order-in-code-first)
Comments: __EF Team Triage:__ We agree that we should fix this issue. Given that this is not a regression from a previous release we are not going to take a fix in the 6.1.2 patch release. We're moving it to the Future release to reconsider for the next release. Also marking as UpForGrabs in case someone outside of the EF team wants to contribute the fix.

Edited Feature: UpForGrabs: Create indexes with included columns [2451]

$
0
0
I would like to be able to include columns for an index. By either using IndexAttribute or fluent api.

[Create Indexes with Included Columns](http://msdn.microsoft.com/en-us/library/ms190806.aspx)

Commented Feature: UpForGrabs: Create indexes with included columns [2451]

$
0
0
I would like to be able to include columns for an index. By either using IndexAttribute or fluent api.

[Create Indexes with Included Columns](http://msdn.microsoft.com/en-us/library/ms190806.aspx)
Comments: __EF Team Triage:__ We agree that we should fix this issue. Given that this is not a regression from a previous release we are not going to take a fix in the 6.1.2 patch release. We're moving it to the Future release to reconsider for the next release. Also marking as UpForGrabs in case someone outside of the EF team wants to contribute the fix.

Closed Unassigned: Entity Not Updating [2438]

$
0
0
It appears there may be an issue when an entity has a virtual property of the same type as the entity (e.g. Employee has a supervisor who is also an employee.) Here are the general steps to recreate the bug:

1. Create an MVC web application
2. Create an Employee model (string Name, virtual Employee supervisor)
3. Create the necessary dbcontext and add a dbset for the Employee entities
4. Create a controller for the Employee model with CRUD using the dbcontext created in the previous step.
5. Launch the website.
6. Using the create view, create two employees with no supervisor (so you only have two employee in the database)
7. Stop debugging
8. In the create and edit action, hard code the supervisor for the employee by setting the property equal to db.Employees.SingleOrDefault(x=>x.Id==1) *Note: this is to minimize the need of creating the selectlist pieces for the model/view/controller
9. Launch the website.
10. Using the create view, create another employee. Using the server explorer, you will notice the supervisor is added to the entity in the database
11. Edit one of the employees that doesn't have a supervisor and you will notice the supervisor doesn't update in the database.

Add in some breakpoints to walk through the process, and you will see that the supervisor property is set for the employee, but the db.Entry(employee).State = EntryState.Modified doesn't work.
Comments: __EF Team Triage:__ Closing as additional details that we requested have not been provided.
Viewing all 10318 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>