开发者

Best approach where Database schema can be changed?

开发者 https://www.devze.com 2023-03-07 08:05 出处:网络
I know about various technique (but not knowledge) Like Code Generator, ORMs etc, I want to know which is the best approach where the schema of database can be changed (big changes) during development

I know about various technique (but not knowledge) Like Code Generator, ORMs etc, I want to know which is the best approach where the schema of database can be changed (big changes) during development period, like add column to Table, add table to DB, change Type of Column etc. I am currently working on a project in this schema changed every day I am using manual process to create BLL, BOL and DAL but I am facing problem to manage these layers after changing the schema of DB. Please advise me how can make this 开发者_StackOverfloweasy?

  1. which technique I have to use Code generator, ORM, Manual approach or any other?
  2. performance also be good.


That is not about programming but about project management. Management / client must understand that changing data schema so often will have very big impact on the development time. It is absolutely not important which technology will you use because even with good code generation tool you can end up with 4+ hours per day fixing broken code by missing properties, new properties, different entities etc. Make sure that you show the amount of time spend on this activity. Show it regularly. Once management sees that from 20MD you spend 10MD on changing your data access layer (= no business value added for 10MD) they will do something with that.

From technology point of view you can use anything that generates classes for you:

  • Linq-to-sql
  • EF with EDMX
  • EF with code-first and EF Power Tools CTP1 to create mapping for you

Or you can do the more complex way with NHibernate where you will manually try to remap new schema to your existing entities.

Edit:

Depending on the type and complexity of the application you can also check ASP.NET Dynamic Data or MVC Scaffolding.


This sounds like a problem that is well suited to code generation.

Some ORMs do code generation for you behind the scenes, but usually only the DAL.

Something like mygeneration may be more suitable to generate all layers.

Performance will be entirely up to how you structure your code templates.

Non of this will help with the fact that you need to redo the work over and over, however.


I also agree that code generation is a suitable technique here. My approach would be to build a model of your database schema. You would then use a code generation framework to build your necessary code. My tool of choice is AtomWeaver but you could also try EMF or even Xtext.

In the AtomWeaver IDE you build a model of your DB schema using the ABSE modeling approach. This approach lets you build a model by blocks (think "table", "column", "key", etc.). For each "block" you define what to generate for your BLL, BOL or DAL. Each time you make a change, you can regenerate again.

There are no pre-defined code generators for databases, which means you'll have to supply all the necessary code to the generating templates, but at least you'll get 100% "your code". Because you already do it manually, you can use that code to "feed" the generator templates.

Building code generators takes some time. It doesn't seem to pay off at first, but as soon as you start changing and being able to get new code fast, you'll change your mind I guess.


ADO.NET Entity Framework is a good one.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号