2
votes

object does not contain a definition for Database and no extension method Database accepting a first argument of type object could be found (are you missing a using directive or an assembly reference?)

enter image description here

enter image description here UserStore userStore = new UserStore();

    userStore.Context.Database.Connection = System.Configuration.ConfigurationManager.
        ConnectionStrings["CartDBConnectionString"].ConnectionString;

    UserManager<IdentityUser> manager = new UserManager<IdentityUser>(userStore);
1
my version of .net is 4.7.02556Lasith Jayalath
try to understand the error messages you are getting from the compiler. Your error message indicates that you are trying to use an object in your code that is not properly referenced. This is common and you should get used to resolving this. "Referencing" means that you have to let the class that it will require a library (or DLL) which is often done by the "Using" key word. The image you have posted also implies missing libraries but not necessarily the one you have posted.DaniDev
@DaniDev I have tried several libraries but how I can find the exact libraryLasith Jayalath
Thanks for accepting my answer. May I edit the title of your question so that it can be (more) useful to others?DaniDev
@DaniDev yes for sure. I am still a beginner..I am still stuck with this problem.But with your answer I think I can solve itLasith Jayalath

1 Answers

1
votes

Based on the image you supplied you are missing a reference to the following library:

Microsoft.AspNet.Identity.EntityFramework

You can often figure out which Library you are missing by looking up (in MSDN) the object that is giving you the error. In your case (according to your image) the object was IdentityUser . If you do a look up: IdentityUser

It will point you to the missing assembly I indicated above.

You (first) need to create a reference to this library for you project:

Adding Reference

then add it to your code with the Using Keyword: using directive or Using KeyWord

The error message you posted:

'object' does not contain a definition for 'Database' and no extension method 'Database' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

is a little ambiguous and implies another bad/missing reference but I would need to see the code that is triggering that message.