Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is ADO.NET Entity framework database schema update possible?

I'm working on proof of concept application like crm and i need your some advice. My application's data layer completely dynamic and run onto EF 3.5. When the user update the entity, change relation or add new column to the database, first i'm planning make for these with custom classes. After I rebuild my database model layer with new changes during the application runtime. And my model layer tie with tightly coupled to my project for easy reflecting model layer changes (It connected to my project via interfaces and loading onto to application domain in the runtime).

I need to create dynamic entities, create entity relations and modify them during the runtime after that i need to create change database script for updating database schema. I know ADO.NET team says "we will be able to provide this property in EF 4.0", but i don't need to wait for them.

How can i update database changes during the runtime via EF 3.5 ?

For example, i need to create new entity or need to change some entity schema, add new properties or change property types after than how can apply these changes on the physical database schema ?

Any ideas ?

like image 414
fyasar Avatar asked Oct 09 '09 23:10

fyasar


People also ask

Can database schema be changed?

A schema change is an alteration made to a collection of logical structures (or schema objects) in a database. Schema changes are generally made using structured query language (SQL) and are typically implemented during maintenance windows.

How do I update the table schema in Entity Framework?

Drop and Recreate Your Database You can configure Entity Framework to delete (drop) and recreate your database every time there is a change to your schema. To do this, you need to create an initializer class in the same folder as your DbContext class. The class needs to inherit from DropCreateDatabaseIfModelChanges .

Why ADO.NET is faster than Entity Framework?

Because ADO.NET always establishes the connection directly to the database. That's why it provides much better performance compared to the Entity Framework. It is because, in Entity Framework, the entity first translates the LINQ queries to SQL and then it processes the query to perform database operations.


1 Answers

This blog post may have what you need. It describes a way to capture the metadata of your model and modify it in-transit, during runtime. I haven't a clue how it works, but it sounds cool.

Changing Entity Framework storage DB schema during Runtime http://blogs.microsoft.co.il/blogs/idof/archive/2008/08/22/change-entity-framework-storage-db-schema-in-runtime.aspx

like image 185
Robert Harvey Avatar answered Oct 11 '22 17:10

Robert Harvey