ASP.Net MVC: Best Practices for dbml files

前端 未结 3 1894
挽巷
挽巷 2021-01-01 00:42

This may just be a yes or no type of question but here goes anyway...

From all (well most) of the examples that I\'ve seen for using mvc, it appears that method for

3条回答
  •  春和景丽
    2021-01-01 01:01

    Personally I prefer to create the classes/association in the .dbml and then generate the database from that.

    Just add the following class to your project

    partial class MyDataContext {
        partial void OnCreated() {
            if (!DatabaseExists())
                CreateDatabase();
            }
    }
    

提交回复
热议问题