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

Commented Feature: UpForGrabs: Cached Connection String Refresh - Feature Request [2371]

$
0
0

Visual Studio 2013 Ultimate, WinForms .Net 4.5.1 and Entity Framework 6.1.1 Code First

Application requires a change to app.config connection string while the application is running when a db server is not present. Code works great at updating the App.Config, saving it and refreshing it. The ConfigurationManager has no problem seeing the new connection string. ADO.Net has no issue reading in the new SQL Connection string however when I apply this to Entity Framework the connection string is not updated.

It appears that on load EF caches the ConnectionString and there is no way to update it even with a ConfigurationManager.RefreshSection(strSectionName). I have a DBContext in a different layer that is inherited so it not practical to set the connection string on each child (context.Connection.ConnectionString=). Sure I can update the constructor to use the new value when its changed but I do not want to touch a constructor and manually set ConnectionString when the framework should do that for me.

Feature: Would like to call a method in EF that refreshes the connection strings from the running config file and updates the cache.


http://social.msdn.microsoft.com/Forums/en-US/aeb91873-1f42-4f36-89cc-e43a8a9ec95f/entity-framework-611-caching-connection-string?forum=adodotnetentityframework

Comments: Hi, I've found my workaround: ``` public Model() : base(((ConnectionStringsSection) ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).GetSection("connectionStrings")).ConnectionStrings["MySqlConnection"].ConnectionString) { //This constructor works if connectionstring is changed at runtime... } ``` May it help... François

Created Unassigned: Entity Framework 6 - Second level Caching Alias name [2956]

$
0
0
Hi,

I am using Entity Framework 6 and using second level of caching of entities to improve performance.

One of the problems we are facing is with the Alias names in the query.

On a high load scenario, the alias name generated for a query are different which is resulting in both the queries being treated as different and it breaks the caching.

For Eg:
SELECT Var_251.id from user Var_251 where <<condition1>>

The same query for the user on a high load is getting generated as
SELECT Var_252.id from user var_252 where <<Condition1>>

since both the queries are different, the hash of the query which is used as a key to store the result set becomes different. So data cached in the first query is not reusable in second query by the same user.

IF we run the application with a single user the query alias name generated is always same, but the moment to move say 5+ user load, the query being generated gets different.

So just wanted to confirm if there is a way to override this default behaviour so that it uses the same alias everytime for the query or if this is a known issue in the EF 6.







Commented Unassigned: Entity Framework 6 - Second level Caching Alias name [2956]

$
0
0
Hi,

I am using Entity Framework 6 and using second level of caching of entities to improve performance.

One of the problems we are facing is with the Alias names in the query.

On a high load scenario, the alias name generated for a query are different which is resulting in both the queries being treated as different and it breaks the caching.

For Eg:
SELECT Var_251.id from user Var_251 where <<condition1>>

The same query for the user on a high load is getting generated as
SELECT Var_252.id from user var_252 where <<Condition1>>

since both the queries are different, the hash of the query which is used as a key to store the result set becomes different. So data cached in the first query is not reusable in second query by the same user.

IF we run the application with a single user the query alias name generated is always same, but the moment to move say 5+ user load, the query being generated gets different.

So just wanted to confirm if there is a way to override this default behaviour so that it uses the same alias everytime for the query or if this is a known issue in the EF 6.







Comments: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). Please file your issue on the GitHub issue tracker. **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Closed Unassigned: Entity Framework 6 - Second level Caching Alias name [2956]

$
0
0
Hi,

I am using Entity Framework 6 and using second level of caching of entities to improve performance.

One of the problems we are facing is with the Alias names in the query.

On a high load scenario, the alias name generated for a query are different which is resulting in both the queries being treated as different and it breaks the caching.

For Eg:
SELECT Var_251.id from user Var_251 where <<condition1>>

The same query for the user on a high load is getting generated as
SELECT Var_252.id from user var_252 where <<Condition1>>

since both the queries are different, the hash of the query which is used as a key to store the result set becomes different. So data cached in the first query is not reusable in second query by the same user.

IF we run the application with a single user the query alias name generated is always same, but the moment to move say 5+ user load, the query being generated gets different.

So just wanted to confirm if there is a way to override this default behaviour so that it uses the same alias everytime for the query or if this is a known issue in the EF 6.







Closed Unassigned: SQL Server 2016 and EF 6.1.3 Change Detection issue [2955]

$
0
0
We recently upgraded to SQL Server 2016 and have found a compatibility issue with EF 6.1.3 Code First. What we're seeing is that datetime data types are being detected as changed, when they haven't actually changed, which is causing records to be written to the database when they shouldn't, which is causing concurrency exceptions when we check against timestamps.

If we change the database compatibility to 2014, everything works as expected.

When in 2016 compatibility mode, the following sql statement will be generated by EF, but this statement does not appear when running against previous versions of SQL Server. Note that the field in question (StateLastChangedDate) is NOT changing:

exec sp_executesql N'UPDATE [dbo].[TranslationTarget]
SET [StateLastChangedDate] = @0
WHERE (([Id] = @1) AND ([LastEdited] = @2))
SELECT [LastEdited]
FROM [dbo].[TranslationTarget]
WHERE @@ROWCOUNT > 0 AND [Id] = @1',N'@0 datetime2(7),@1 uniqueidentifier,@2 binary(8)',@0='2016-08-19 14:36:31.1233333',@1='725DE153-266D-43A1-9811-D63FEE3DFA22',@2=0x0000000000002AC4

The field is defined as:

[StateLastChangedDate] [datetime] NULL,

When we look at our audit records, we see repeated updates for that table, all with exactly the same values, other than the RowVersion column.

For example, a single update produce the following StateLastChangedDate updates (note how they're all the same):
2016-08-19 14:36:31.123
2016-08-19 14:36:31.123
2016-08-19 14:36:31.123
2016-08-19 14:36:31.123
2016-08-19 14:36:31.123

Help? :)
Comments: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). Please file your issue on the GitHub issue tracker. **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Closed Unassigned: Projection of entities with includes does not bring in the included property [2954]

$
0
0
I have a query as follows

db.parentItem.include(e => e.child).select(function(e) new {entity = e, countofotherchildren = e.otherchildren.count()}).single()

this returns an entity with out the child property filled in

I can get around this by manually selecting the child property but I believe the include should be enough
Comments: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). Please file your issue on the GitHub issue tracker. **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Closed Unassigned: Download of source freezes constantly at 7.7MB [2953]

$
0
0
HOw is it possible that the download ALWAYS stops at 7.7MB???????? when using chrome in windows 10 even when other download run correctly. I don't care if you want to blame chrome, but with your record of continuous fuckups, I would think twice before accusing other parties!!!!!

I'm fed up with the fucking bugs in windows 10 due to retarded developers that only know how to crawl up marketing's ass instead of using their brains!!!!!!!!!!!!!!!!!!!!!!!!
Comments: This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Created Unassigned: Can't configure one-to-many relationship with intermediary wrapper class [2957]

$
0
0
My original post to this question is here on [Stack Overflow](http://stackoverflow.com/questions/39475156/how-to-configure-one-to-many-relationship-with-intermediary-wrapper-class-in-ent)

Short version:
I am having issues configuring a one-to-many relationship through use of an intermediary wrapper class. I want entity 'A' to have a one-to-many relationship to entity 'C'. Entity 'A' has a property called class 'B' (this is the wrapper class) that contains a collection of entity 'C's. In addition, I don't want class 'B' to be represented in the database whatsoever.

I'd like to know if this scenario is solvable in EF 6.1. I haven't looked into EF7 so if this isn't an issue there then that would be great to know as well.

My struggle:
1) I want to hide class B by using [NotMapped] or the ignore fluent api, but in doing so the one-to-many relationship won't be visible to EF.
2) I want to make class B a complex type but complex types are unable to participate in association.

Commented Issue: Entity Model Association Layout Issues [738]

$
0
0
I'm having two issues with the entity association lines. The first involves the persistence of the association lines after closing VS 2012 and reloading the project. They are not how I had manually positioned them. Secondly, the auto layout of the lines, after reloading the project, has some quirks. The attached image demonstrates this.
Comments: I can confirm this issue still exists in EF6. Any chance of this getting fixed? It can be very annoying for large models.

Created Unassigned: Ef power tools - Exception has been thrown by the target of and invocation [2958]

$
0
0
When I right click on Entity framework->Generate Views I got this message displayed
"Exception has been thrown by the target of and invocation".

It used to work alright until last week. Around the same time as Anniversary update for windows 10 was installed. I don't know i there is some issue with that version.

Edited Unassigned: Ef power tools - Exception has been thrown by the target of and invocation [2958]

$
0
0
When I right click on Entity framework->Generate Views I got this message displayed
"Exception has been thrown by the target of and invocation".

It used to work alright until last week. Around the same time as Anniversary update for windows 10 was installed. I don't know i there is some issue with that version.

I'm using Visual studio 2013 and I target .net framework 4.

Closed Unassigned: Ef power tools - Exception has been thrown by the target of and invocation [2958]

$
0
0
When I right click on Entity framework->Generate Views I got this message displayed
"Exception has been thrown by the target of and invocation".

It used to work alright until last week. Around the same time as Anniversary update for windows 10 was installed. I don't know i there is some issue with that version.

I'm using Visual studio 2013 and I target .net framework 4.
Comments: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). Please file your issue on the GitHub issue tracker. **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Closed Unassigned: Can't configure one-to-many relationship with intermediary wrapper class [2957]

$
0
0
My original post to this question is here on [Stack Overflow](http://stackoverflow.com/questions/39475156/how-to-configure-one-to-many-relationship-with-intermediary-wrapper-class-in-ent)

Short version:
I am having issues configuring a one-to-many relationship through use of an intermediary wrapper class. I want entity 'A' to have a one-to-many relationship to entity 'C'. Entity 'A' has a property called class 'B' (this is the wrapper class) that contains a collection of entity 'C's. In addition, I don't want class 'B' to be represented in the database whatsoever.

I'd like to know if this scenario is solvable in EF 6.1. I haven't looked into EF7 so if this isn't an issue there then that would be great to know as well.

My struggle:
1) I want to hide class B by using [NotMapped] or the ignore fluent api, but in doing so the one-to-many relationship won't be visible to EF.
2) I want to make class B a complex type but complex types are unable to participate in association.
Comments: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub (https://github.com/aspnet/EntityFramework6). Please file your issue on the GitHub issue tracker. **We will no longer be monitoring this issue tracker for comments, so please do not reply here.**

Commented Issue: UpForGrabs: Similar named properties cause AmbiguousMatchException error [2541]

$
0
0
We have an entity class generated using Reverse POCO Generator. This class has the following two properties among other properties:

```
public int AcctType { get; set; } // acct_type. FK into accttype
// Foreign keys
public virtual Accttype Accttype { get; set; } // FK_accounts_accttype
```

It also has a configuration file with the following lines:
```
public AccountsConfiguration(string schema = "dbo")
{
ToTable(schema + ".accounts");
HasKey(x => x.AcctName);
Property(x => x.AcctType).HasColumnName("acct_type");
...

// Foreign keys
HasRequired(a => a.Accttype).WithMany(b => b.Accounts).HasForeignKey(c => c.AcctType); // FK_accounts_accttype
}
```

Using this class, I am getting the AmbigiousMatchException on the following line of code

```
if (entityState == EntityState.Detached)
{
_dbSet.Attach(entity); // Error here
}

```
If I comment out the virtual property and the configuration info for that property, everything works.

Since this class is auto-generated, we need to find a good solution for this problem. I believe it's a bug in EF.
Comments: In our case we had to alter our database and change table name to avoid ambiguity.

Commented Feature: UpForGrabs: Migrations: -Script for Migrate.exe [251]

$
0
0
http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx#10301435

Marcel Bradea

05-05-2012 1:09 PM
#

I noticed the migrate.exe command line tool does not have a "-script" equivalent of the NuGet tool. This would be tremendously useful since you usually don't want to run any migrations without generating and verifying the scripts that get applied to the database first. It is the ultimate say of what goes into the DB and is a key part of the developer workflow of using migrations. Without it you would be forced to back up the local database, run the changes directly against the database and revert if they don't come out quite as expected.

Are you currently considering adding this functionality to the command-line tool?

The generated .sql script file could get placed into the same directory as migrate.exe or the '/StartUpDirectory' directory.

Comments: [Pull request](https://github.com/aspnet/EntityFramework6/pull/87) on Github.

Reviewed: EF 5.0.0 (十一月 01, 2016)

$
0
0
Rated 5 Stars (out of 5) - 居然是要回复才能下载吗?试一下

Created Unassigned: Schema breaking when attempting to reuse entity in Table Valued Function return type [2959]

$
0
0
This question is primarily about another framework, https://github.com/Dixin/EntityFramework.Functions which adds code-first support for things like Table Valued Functions.

I'm investigating why, when you try to reuse an entity type as a return type for a function, it breaks the schema representation of the database within EF. Specifically, I get these errors:

> Schema specified is not valid. Errors:
(0,0) : error 0040: The Type Int32 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(0,0) : error 0040: The Type String is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(0,0) : error 0040: The Type Int32 is not qualified with a namespace or alias. Only primitive types can be used without qualification.
(0,0) : error 0040: The Type Int32 is not qualified with a namespace or alias. Only primitive types can be used without qualification.

The types referenced by these errors match the four properties within the model I'm attempting to reuse.

As I read the code for entityframework.functions, the return type for the function is constructed here

https://github.com/Dixin/EntityFramework.Functions/blob/master/EntityFramework.Functions/Function.DbModel.cs#L439

The relevant lines where the RowType is created

EntityType modelReturnParameterEntityType = modelReturnParameterStructuralType as EntityType;
if (modelReturnParameterEntityType != null)
{
storeReturnParameterRowType = RowType.Create(
modelReturnParameterEntityType.Properties.Select(property => property.Clone()),
null);
}

The result seems valid and is added to the ModelStore. The conceptual model is created, and the return value is generated here

https://github.com/Dixin/EntityFramework.Functions/blob/master/EntityFramework.Functions/Function.DbModel.cs#L568

The relevant portion of the method is here

if (functionAttribute.Type == FunctionType.TableValuedFunction)
{
// returnParameterInfo.ParameterType is IQueryable<T>.
Type returnParameterClrType = returnParameterInfo.ParameterType.GetGenericArguments().Single();
StructuralType modelReturnParameterStructuralType = model.GetModelStructualType(returnParameterClrType, methodInfo);
modelReturnParameterEdmTypes = Enumerable.Repeat(modelReturnParameterStructuralType, 1);
}

Again it appears that the already-defined model is found and used to generate the return value. Everything looks correct, and is added to the ConceptualModel.

For some reason this appears to break the schema of my model. I kinda doubt the answer as to why and the solution to fix it won't be initially obvious. But any hints/suggestions as to what might be happening and why, and how it might be fixed would be appreciated. A demo app is attached. I might have killed the entityframework.functions project when trying to get the zip in under the weight limit. If so, you can re-download it from the GitHub repository.

Commented Issue: Support method overloads for default parameters with Database first [805]

$
0
0
When using Database first to generate a model from an existing database for stored procedures, only a single method call is generated that does not take into account default parameters the stored procedure may have. This effectively means there is no way to call mapped stored procedures without having to write the code by hand, negating the point of generating a model from the data
Comments: Any changes to this?

Created Unassigned: DbSet.SqlQuery for entities with complex types [2960]

$
0
0
When DbSet.SqlQuery is used to retrieve entities that contain complex types as properties, the following exception is thrown.

System.InvalidOperationException: Cannot create a value for property '{name}' of type '{complex-type}'. Only properties of primitive or enumeration types are supported.

Example:


public class MyDbContext : DbContext
{
public DbSet<Person> People { get; set; }
}

public class Person
{
public virtual int Id { get; set; }
public virtual PersonName Name { get; set; }
}

public class PersonName
{
public string First { get; set; }
public string Last { get; set; }
}

class Program
{
static void Main(string[] args)
{
using (var db = new MyDbContext())
{
var query = db.People.SqlQuery("SELECT [Id], [Name_First], [Name_Last] FROM [dbo].[People]");
query.Count(); // throws exception
query.ToList(); // throws exception
}
}
}


Created Unassigned: Error Entity Framework When use store procedure has the transaction [2961]

$
0
0
I get the error in entity framework when use store procedure has the transaction syntax. The store procedure successfully when execute use ADO.Net but i get this Error
> Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0


Any Solution ?
Thanks and regards,
Bahar
Viewing all 10318 articles
Browse latest View live




Latest Images