1.Code First第一次启动会对比程序中的Model与数据库表(database initializer ),生成Model与数据库的映射视图。使用ef6的情况下,在Application_Start里面添加
using (var dbcontext = new NCContext()) { var objectContext = ((IObjectContextAdapter)dbcontext).ObjectContext; var mappingCollection = (StorageMappingItemCollection)objectContext.MetadataWorkspace.GetItemCollection(DataSpace.CSSpace); mappingCollection.GenerateViews(new List<EdmSchemaError>()); }
原文地址:https://www.cnblogs.com/shuajing/p/EF.html
时间: 2024-10-16 09:54:56