Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I wrote the following code for mapping model classes to existing database but after creating the controller and executing app am getting exception as "Invalid object name 'dbo.ProductGroups"

web.config:
XML
<connectionStrings>
<add name="DatabaseContext" connectionString="Data Source= ACER-PC; Integrated Security=true;Initial Catalog=Practise; uid=sa; Password=srujana; " providerName="System.Data.SqlClient" />
</connectionStrings>

DatabaseContext Class:
C#
public class DatabaseContext:DbContext
{

public DbSet<Product> Products { get; set; }
public DbSet<ProductGroup> ProductGroups { get; set; }

}

model classes:

public class ProductGroup
{
[Key]
public int ProductGroupID { get; set; }

[Required]
public int ProductGroupName { get; set; }

[Required]
public string Country { get; set; }

[StringLength(255)]
public string CreatedBy { get; set; }

[ScriptIgnore]
public virtual ICollection<Product> Products { get; set; }
Posted
Updated 13-Apr-13 4:45am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900