tags:

views:

505

answers:

2

Is there a way to generate the DBML file from entity classes instead from database tables? This would be very useful for prototyping, where one just creates a logical model and let's the auto-generated tool to create the DBML file. With DBML file, one can use SqlMetal to generate Linq to SQL classes and be done with it. So, to prototype rapidly, one would:

1.Define models

public class Person
{
    public string Name { get; set; }
    public int Age { get; set; }
    // etc
}

2.Run the tool (with chosen entities)

3.Get the auto-generated DBML file

4.Run the SqlMetal tool or Damiens t4 scripts to create Linq to SQL classes

5.Code against auto-generated data-context and auto-generated database (using DataContext.CreateDatabase() to create the intial DB, for instance). Some sort of DB migration would be even nicer.

Or am I weird for wanting to generate DB from objects instead of objects from DB? :)

+1  A: 

Doesn't exist. Currently the only method of generate a DBML for Linq to SQL is from a sql database source.

This might someday exist for the Entity Framework but current not there either.

Andrew Robinson
A: 
Dmitri Nesteruk