Je potrebno dodati Reference? C#
1 naročnik
1 naročnik
Pozdravljeni.
Zanima me zakaj mi pri tej kodi:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DatabaseFirstSample
{
class Program
{
static void Main(string[] args)
{
using (var db = new BloggingContext())
{
// Naredi in shrani nov blog
Console.Write("Vpiši ime za nov blog: ");
var name = Console.ReadLine();
var blog = new Blog{ Name = name };
db.Blogs.Add(blog);
db.SaveChanges();
// Pokaži vse blog v podatkovni bazi
var query = from b in db.Blogs
orderby b.Name
select b;
Console.WriteLine("Vsi blogi v podatkovni bazi:");
foreach (var item in query)
{
Console.WriteLine(item.Name);
}
Console.WriteLine("Pritisni gumb za izhod...");
Console.ReadKey();
}
}
}
}
Izpiše ta prolem pri ADD:
Error 2 'System.Data.Objects.ObjectSet<DatabaseFirstSample.Blog>' does not contain a definition for 'Add' and no extension method 'Add' accepting a first argument of type 'System.Data.Objects.ObjectSet<DatabaseFirstSample.Blog>' could be found (are you missing a using directive or an assembly reference?)
Ali morem dodati kakšno referenc-o ali kaj?
Ali je problem kje drugje?
2 odgovora
No sporočam, da sem rešil kar hitro stvar sem dobil potem na eni spletni strani:
Namesto .ADD sem dal .AddObject če bo kdo kdaj potreboval.
Mam pa še eno napako:
Error 1 Running transformation: Please overwrite the replacement token '$edmxInputFile$' with the actual name of the .edmx file you would like to generate from. 1 1 DatabaseFirstSample
Lp