c# 4.0 - asp.net unable to retrieve metadata -


hi having issue mvc make controller after reading tips. adding constructor on dbcontext, deleting non worked, changing providername="system.data.sqlclient" , on.

my model class this:

public class recruitermodel {     public string companyname { get; set; }     public string website { get; set; }     public string companysize { get; set; }     public string linkedincompanyurl { get; set; }     public string linkedinid { get; set; }     public string specialities { get; set; }     public string category { get; set; }     public string location { get; set; }     public int contactphone { get; set; }     public string contactemail { get; set; } }  public class recruiterdbcontext : dbcontext {      public dbset<recruitermodel> recruiters { get; set; } } 

and web.config connectionstrings looks this:

<add name="applicationservices"      connectionstring="data source=.\sqlexpress;integrated  security=sspi;attachdbfilename=|datadirectory|aspnetdb.mdf;user instance=true"      providername="system.data.sqlclient" /> <add name="recruiterdbcontext"      connectionstring="data source=(localdb)\v11.0;attachdbfilename=|datadirectory|\recruiters.mdf;integrated security=true"      providername="system.data.sqlclient" /> 

any tips?

add following property recruiter class:

public string id { get; set; } 

or apply key attribute 1 of existing properties. example:

[key] public string companyname { get; set; } 

on msdn, have code first conventions topic:

primary key convention

code first infers property primary key if property on class named “id” (not case sensitive), or class name followed "id". if type of primary key property numeric or guid configured identity column.

public class department {     // primary key     public int departmentid { get; set; }      . . .      } 

another reference on topic made in code first dataannotations article:

key

entity framework relies on every entity having key value (aka entitykey) uses tracking entities. 1 of conventions code first depends on how implies property key in each of code first classes. convention to property named “id” or 1 combines class name , “id”, such “blogid”. in addition ef’s use of entitykey, property map primary key column in database.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -