Reputation: 737
There are a lot of Sql table -> C# class methodologies, but I'm looking for the reverse.
Hypothetical situation:
I have N classes populated by some web service I consume, manipulate, then preform an action on. Now the boss wants said web service data persisted in a database.
I already have the classes defined, how can I quickly and easily (aka, lazily) generate a sql table off of each class?
Upvotes: 1
Views: 8628
Reputation: 6062
Entity framework 4 has a code first development feature, I haven't used it so can't really recommend it
Upvotes: 0
Reputation: 44605
you can use MS Entity Framework Code First approach:
Code First allows you to define your model using C# or VB.Net classes, optionally additional configuration can be performed using attributes on your classes and properties or by using a Fluent API. Your model can be used to generate a database schema or to map to an existing database.
read more about it here: EF 4.1 Code First Walkthrough
Upvotes: 1
Reputation: 22245
Entity Framework and nHibernate both allow you to use them in "code-first" mode, which involves writing classes then generating databases.
There is a walk-through of this on ScottGu's blog here: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework-4.aspx
Upvotes: 3