0

我使用简单的控制台应用程序和数据库并生成 .edmx 文件。当我插入新行并跟踪更新时,我发现一切正常。但是当我去查看我的数据库的内容时,我没有看到任何变化。看起来我已经更新了我的数据库的“内存实例”。我应该在我的 ConnectionString OR/AND .edmx 文件中更改什么以更新真实数据库?
更新

    <connectionStrings>
            <add name="ProductsEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\Products.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    </connectionStrings>


    static void Main(string[] args)
    {
         var context = new ProductsEntities(ConfigurationManager.ConnectionStrings["ProductsEntities"].ConnectionString);
         var productForInsert = new Product {CompanyName = "Insert Name", Price = new decimal(22), Description = "dd", Name = "ddd"};
         context.Products.AddObject(productForInsert);
         context.SaveChanges();
         // return only new row as expected ([database rows].CompanyName == "Toshiba")
         // tracking database rows returns expected result too
         var result = context.Products.Where(p => p.CompanyName != "Toshiba");
         foreach (var b in result)
         {
            Console.WriteLine(b.CompanyName);
         }
    }
4

0 回答 0