Quantcast
Channel: entityframework Discussions Rss Feed
Viewing all 1793 articles
Browse latest View live

New Post: Entity Framework calls AssemblyName.ReferenceMatchesDefinition which is undefined in Mono

$
0
0
Since ReferenceMatchesDefinition() is a simple comparison, I implemented it in Mono and sent them a PR which just got accepted. This should now make it easier to run EF on Mono until the API call is removed from EF.

New Post: EntityFunctions.DiffMilliseconds overflow because its only INT32 !!!

$
0
0
@montage I have created an issue to track this. https://entityframework.codeplex.com/workitem/1627

The way this function is mapped to SQL Server means that the SQL generated can only handle 32-bit results. These functions were defined some time ago, but it seems that at the time the signatures were decided on by what a few common database systems could handle. I'm guessing that it was therefore defined this way because it could be reasonably implemented by those common database systems.

Thanks,
Arthur

New Post: Entity Framework calls AssemblyName.ReferenceMatchesDefinition which is undefined in Mono

$
0
0
Good news! Thanks for the update!

New Post: Entity Framework calls AssemblyName.ReferenceMatchesDefinition which is undefined in Mono

$
0
0
I've now managed to get a simple EF6 Code-First application working on Mono ;-)

There's only one part left that's causing trouble, for which I've filed a bug: #1632

New Post: Entity Framework calls AssemblyName.ReferenceMatchesDefinition which is undefined in Mono

$
0
0
Thanks for the update. That is great!

New Post: TransactionScope and Added Entities

$
0
0
In addition to what Arthur said, a couple of points:
  • Perhaps your expectation is that DbContext itself would be transactional and that changes recorded in memory would be rolled back if the transaction fails on the database, but that is not the case. DbContext is designed (as Arthur explained) to help you collect in memory the changes that happen in your transactions but it is not transactional.
  • If by "run the process again" you mean that the way your application deals with the failure is to start the process "from scratch", i.e. by recording all the changes that need to be applied and entities that need to be added once more, then you should modify your application to throw away the DbContext instance used in the first try (which as Arthur mentioned, will be left ready to call SaveChanges again) and do this with a new (and empty) DbContext instance every time. Otherwise it is expected that you will end up with duplicate information added, and possibly with some failures for deletes and updates.
HTH,
Diego

New Post: Is EF6 rc2 coming out anytime soon?

$
0
0
Is the current RC in a go-live state? Since VS2013 just got released with go live.

New Post: EF6 auto created Stored Procedures for CRUD

$
0
0
IN EntityFramework 6 documentation page, in "Concurrency Tokens" section says: (link to document)
Concurrency Tokens
•Update and delete stored procedures may also need to deal with concurrency:
•If the entity contains any concurrency tokens, the stored procedure should have an output parameter named RowsAffected that returns the number of rows updated/deleted.

I created EF6 Code First project, and SQL Server 2012 database, stored procedures also created automatically. But UPDATE and DELETE doesn't have any RowsAffected parameter. Why?

But in documentation it's there.

Documentation shows POCO and Update Storage procedure as:
public class Person
{
  public int PersonId { get; set; }
  public string Name { get; set; }
  [Timestamp]
  public byte[] Timestamp { get; set; }
}

CREATE PROCEDURE [dbo].[Person_Update] 
  @PersonId int, 
  @Name nvarchar(max), 
  @Timestamp_Original rowversion, 
  @RowsAffected int OUTPUT      -- ====> !!!!!
AS 
BEGIN
  UPDATE [dbo].[People]
  SET [Name] = @Name   
  WHERE PersonId = @PersonId AND [Timestamp] = @Timestamp_Original   

  SET @RowsAffected = @@RowCount 
END
and EF6 created this for me.
public partial class POCO
{
    //identy
    public int ID { get; set; }

    // SQL Server Timestamp
    // this.Property(t => t.RowVersion).IsFixedLength().HasMaxLength(8).IsRowVersion();
    public byte[] RowVersion { get; set; }

    public int MiscPropery { get; set; }    
}

EntityFramework 6 created insert stored procedure:
CREATE PROCEDURE [dbo].[POCO_Update]
    @ID [int],
    @RowVersion_Original [rowversion],
    @MiscPropery  [int]
    --                  ------- I hope here: @RowsAffected int OUTPUT 

AS
BEGIN
    UPDATE [dbo].[POCOs]
    SET [MiscPropery] = @MiscPropery  
    WHERE (([ID] = @ID) AND (([RowVersion] = @RowVersion_Original) 
            OR ([RowVersion] IS NULL AND @RowVersion_Original IS NULL)))

    SELECT t0.[RowVersion], t0.[FaturaNo]
    FROM [dbo].[POCOs] AS t0
    WHERE @@ROWCOUNT > 0 AND t0.[ID] = @ID
END


EntityFramework 6 created delete stored procedure:
CREATE PROCEDURE [dbo].[POCO_Delete]
    @ID [int],
    @RowVersion_Original [rowversion]
    --                   ------- I hope here: @RowsAffected int OUTPUT 
AS
BEGIN
    DELETE [dbo].[POCOs]
    WHERE (([ID] = @ID) AND (([RowVersion] = @RowVersion_Original) 
          OR ([RowVersion] IS NULL AND @RowVersion_Original IS NULL)))
END
In stored procedures created by EF 6, there is no @RowsAffected parameter. Why?

What is the correct version of strored procedures?

New Post: EF6 auto created Stored Procedures for CRUD

$
0
0
Hi @ayocak,

We made a late change to only include the rows affected parameter if you explicitly call the RowsAffectedParameter fluent API.

E.g.
modelBuilder
       .Entity<Order>()
       .MapToStoredProcedures(
           map =>
           {
                 map.Update(f => f.RowsAffectedParameter("rows_affected1"));
                 map.Delete(f => f.RowsAffectedParameter("rows_affected2"));
           });
Cheers,
Andrew.

New Post: EF6 auto created Stored Procedures for CRUD

$
0
0
@AndrewPeters, thank you very much. I understand why ...

If i understand correctly, it's also Optional.

I think i must use RowsAffectedParameter. Otherwise (current situation), with SQL Server TimeStamp based optimistic concurrency check, how can EF6 handles update, delete statements correctly? Is it getting @@RowCount from elsewhere or uses any other mechanism -return of ExecuteNonQuery-? Still thinking...

To use SQL Server TimeStamp based optimistic concurrency check, can you give me a suggestion and show me the correct way, even in 'you must use RowsAffectedParameter" or 'no, EF6 handles CRUD operations without RowsAffectedParameter , as in the scenario not uses stored procedures, interacting directly tables '.

New Post: Is DbFunctions.DiffDays implemented?

$
0
0
Hi,

Just checked the source code and it seems to be postponed. If ever, when? :)

Thx,
Lucian

New Post: Is DbFunctions.DiffDays implemented?

$
0
0
@Inaie,

In what way do you mean that it "seems to be postponed"? DbFunctions.DiffDays is a stub method for use in LINQ queries that will be translated into SQL by the EF provider and then executed on the server. We don't have any plans to implement this in .NET code since that is not how this method is intended to be used. If it is not working in a LINQ to Entities query then please let us know.

Thanks,
Arthur

New Post: EF6 auto created Stored Procedures for CRUD

$
0
0
Hi @ayocak,

You are right that we use the return value from ExecuteNonQuery by default. The output parameter is useful if you perform any logic in your sproc that would result in the @@RowCount variable being incorrect (from EF's perspective) at the end of execution.

Cheers,
Andrew.

New Post: EF6 auto created Stored Procedures for CRUD

New Post: Support for ROWGUID and FILEGROUP/Partition in Migrations

$
0
0
Hi Michael,

Thanks for the heads-up. I created #1649 to track this.

Cheers,

Andrew.

New Post: 1st query or save does not use isolation level of TransactionScope

$
0
0
I'm seeing an odd issue when using a TransactionScope, in which the first CRUD operation performed never seems to use the scope's isolation level.

For example, assume code like this (for the record, I am well aware that the TransactionScope is not needed here, I am trying to illustrate what I think is a bug):
[TestMethod]
publicvoid TestTransactionIsolation() {

  var options = new TransactionOptions() { IsolationLevel = IsolationLevel.Serializable, Timeout = TimeSpan.FromMinutes(1) };
  using (var transaction = new TransactionScope(TransactionScopeOption.Required, options)) {
    using (var ctx = new NorthwindEntities()) {
      var cust1 = Customer.CreateCustomer(Guid.NewGuid(), "company a");
      ctx.AddToCustomers(cust1);
      ctx.SaveChanges();

      var cust2 = Customer.CreateCustomer(Guid.NewGuid(), "company b");
      ctx.AddToCustomers(cust2);
      ctx.SaveChanges();
    }
     transaction.Complete();
  }
}
A SQL Profiler trace of the above seems to show that the requested isolation level - serializable - is not used with the first save.
Audit Login set transaction isolation level read committed
RPC:Completed   exec sp_executesql N'INSERT [dbo].[Customer] …
Audit Logout    
RPC:Completed   exec sp_reset_connection 
Audit Login set transaction isolation level serializable 
RPC:Completed   exec sp_executesql N'INSERT [dbo].[Customer]…
Audit Logout    
RPC:Completed   exec sp_reset_connection 
Audit Login set transaction isolation level serializable 
Audit Logout    
This behavior seems to be true regardless of whether the first operation is a query or save, and mixing up the TransactionScope/ObjectContext creation order also has no affect.

An error is not thrown, but based on the trace it does seem that the isolation level is initially ignored.

We see this behavior in EF 5, and in EF 6 RC1.

New Post: How can I use multiples DbContext(Mapping Error) - Module Application EF6

$
0
0
Hi!

I have an application that we have some modules. We have for example FinancialModule and EmployeeModule.

I have an Core project that I created an abstract class called DefaultDbContext that inherits from DbContext and I have an abstract method called ModelCreating that all ConcreteClass (EFFinacialContext and EFEmployeeContext) should implement it to add mapping class.

My problem is that, I have an application with these modules and receiving this message "The entity type MyEntity is not part of the model for the current context."

I have each module in running in another application and everything is okay, so,something is wrong when running together.

Who had the same problem using applications with multiples db context?

Thanks

New Post: EF RC1 much slower than previous version

$
0
0
I've updated my project to use EF RC1, but the project startup got very slower.
The application startup went from 10 seconds to more than 2 minutes.

I have profiled my application, and found out that the slower part is a call to System.Linq.Queryable.OrderBy[System.__Canon,System.__Canon], inside the System.Core.ni.dll module.

Is this a known bug? Is there something I can do to fix it?

Thanks.

New Post: EF RC1 much slower than previous version

$
0
0
Hi diegomodolo, can you provide us with additional information:
  • What version of EF did you upgrade from?
  • What's the size of your model (number of entities, roughly how many fields in your entities, roughly how many foreign keys in your model)?
  • Is it code first or not?
  • Optionally: are you using TPT, TPC or TPH?
    I'm investigating this, your information is valuable to track if this is a regression and how to address it.

New Post: EF RC1 much slower than previous version

$
0
0
Hi @DavidObando.

I'm upgrading from Alpha 3.
My model has 335 entities, with 2050 columns and 600 FKs.

It is code first.

We are using TPT.

Do you want me to send the performance report?

Thanks.
Viewing all 1793 articles
Browse latest View live


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