0

我有以下代码:

DefaultModel.RegisterContext(typeof(YourDataContextType), 
                             new ContextConfiguration() { 
                                 ScaffoldAllTables = true });

我知道“yourdatacontexttype”有什么作用,但我似乎找不到它在哪里。

4

1 回答 1

1

It's usually the name of your .edmx file with 'Entities' appended, so if your edmx is called 'Foo' you're looking for FooEntities. This is of course under the assumption you use database first and have generated an .edmx from your db.

As found here, when you use Code First, you need the following:

Replace

typeof(Models.ProductCatalog)

with

() => new Models.{YourModel}(connectionString).ObjectContext
于 2012-06-27T12:36:50.733 回答