模型存储edmx文件不会在调试模式下生成,但会在发布模式下生成

问题描述 投票:4回答:2

反正我的edmx文件是否在调试模式而不是发布模式下生成?

public class DatabaseConfiguration : DbConfiguration
    {
        public DatabaseConfiguration() : base()
        {
            var modelStoreLocation = Config.Data.ModelStoreLocation;
            if (!modelStoreLocation.IsBlank())
            {
                var cachedDbModelStore = new MyDbModelStore(Config.Data.ModelStoreLocation);
                var dependencyResolver = new SingletonDependencyResolver<DbModelStore>(cachedDbModelStore);
                AddDependencyResolver(dependencyResolver);
            }
        }
.net visual-studio entity-framework ef-code-first edmx
2个回答
0
投票

我认为您的解决方案没有正确构建。因此,当您在发布模式下生成时,它可以正常构建解决方案,然后它也将在调试模式下工作。


-1
投票

如果您想要加载两个不同的edmx文件,一个用于调试,一个用于发布,您可以使用编译指令。

#if DEBUG
var modelStoreLocation = [Debug ModelStoreLocation];
#endif

https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-if

虽然我不确定我会建议使用不同的型号。它包含在恶业中。

© www.soinside.com 2019 - 2024. All rights reserved.