Entities' does not contain a constructor that takes 1 arguments

前端 未结 3 374
借酒劲吻你
借酒劲吻你 2021-01-23 17:32
public class Connection
{
    public static string GetConecction()
    {
        return ConfigurationManager.ConnectionStrings[\"DCAssetEntities\"].ConnectionString;
            


        
相关标签:
3条回答
  • 2021-01-23 18:13

    Make the constructor yourself in a partial class:

    public partial class DCAssetEntities: DbContext
    {
        public DCAssetEntities(string connectionstring)
            : base(connectionstring)
        {
        }
    }
    

    Related question: Entity Connection String Constructor not found in EF 5 and WCF 4.5 at runtime

    0 讨论(0)
  • 2021-01-23 18:22

    Your class DCAssetEntities needs to have a constructor with the following definition.

    public DCAssetEntities(string connectionString){}
    
    0 讨论(0)
  • 2021-01-23 18:34

    You need to mark the constructor as public (or internal).

    0 讨论(0)
提交回复
热议问题