我正在尝试将我的MVC3项目与Postgres 9.1中的数据库连接,我遵循以下链接:
info1,@L_404_1@,info3,为了看起来,我只需要字符串连接即可创建一个Controller.
我有对Mono.Security和Npgsql .dll的引用,我将它们添加到Assembly中
我正在使用此connectionString:
<connectionStrings> <add name="TestPostgresqlContext" connectionString="Metadata=res://*/Models.TestPostgresql.csdl|res://*/Models.TestPostgresql.ssdl|res://*/Models.TestPostgresql.msl;provider=Npgsql.NpgsqlConnection;provider connection string="data source=localhost;initial catalog=testPostgres;persist security info=True;user id=postgres;password=123456;multipleactiveresultsets=True;App=EntityFramework"" providerName="Npgsql.NpgsqlConnection"/> </connectionStrings>
public TestPostgresqlContext() : base("name=TestPostgresqlContext","TestPostgresqlContext") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } public TestPostgresqlContext(string connectionString) : base(connectionString,"TestPostgresqlContext") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } public TestPostgresqlContext(EntityConnection connection) : base(connection,"TestPostgresqlContext") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); }
这是一个更加图形化的想法:
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。