Archive

Archive for April, 2015

CodeFluent Entities vs Entity Framework: Referential Integrity

April 16, 2015 Leave a comment

Referential Integrity is about guarantee that database constraints are not violated. Databases has different concepts to ensure referential integrity such as foreign keys.

Let’s see what CodeFluent Entities and Entity Framework provides to ensure data and referential integrity!

Entity Framework

Entity Framework supports the following concepts:

  • Primary keys

  • Foreign keys (association)

  • On Delete Rule

CodeFluent Entities

CodeFluent Entities supports :

  • Primary Keys

  • Foreign Keys

You can enforce or not foreign key constraints in the database:

Cascade Save and Cascade Delete can be configured on the save screen and when needed you can set custom rules:

We also support unique constraints:

Note that you can also have compound unique constraints.

Conclusion

Entity Framework and CodeFluent Entities provide mechanisms about referential integrity. Foreign key support is limited with Entity Framework and unique constraint only exists with Code-First

CodeFluent Entities supports unique constraints and it is more flexible thanks to delete and update rules. It allows to set data integrity enforcement.

References:

CodeFluent Entities vs Entity Framework: Cascade save

April 15, 2015 Leave a comment

To avoid handling every relations in your data model, you may want to ask your access layer to synchronize update operations across related entities.

Entity Framework

With Entity Framework you will not have any feature available to automate a cascade save treatment. This Framework only offers you the way to save entities in your entire context. This is not really a cascading operation as it can be with the SQL Server “cascade delete” but it can do the tricks.

CodeFluent Entities

With CodeFluent Entities you can add a relation:

Then, you can configure the « save » cascading operations:

 

Cascade Save

 

Unlike the Cascade Delete feature which modify the generated stored procedure, it will only change the C# code:

public partial class Client : // ... 
    {

        public virtual bool Save()
        {
            if ((this._orders != null))
            {
                this.Orders.SaveAll();
            }
            bool localSave = this.BaseSave(false);
            return localSave;
        }

        // ...
    }

Simple and clean!

Conclusion

Entity Framework doesn’t include a cascade save feature.

CodeFluent Entities asks you for every relation  to configure an optional operation mode for your save related operations.

References: